Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get unexpected result #8

Open
ngekoding opened this issue Oct 3, 2021 · 10 comments
Open

Get unexpected result #8

ngekoding opened this issue Oct 3, 2021 · 10 comments

Comments

@ngekoding
Copy link

I just follow the instructions, but got the wrong result.

Here is my code to extract the data

const tajweedRules = require("./tajweed.hafs.uthmani-pause-sajdah.json");

const rules = tajweedRules[8].annotations; // 2:2

const text = "ذَٰلِكَ ٱلْكِتَٰبُ لَا رَيْبَ ۛ فِيهِ ۛ هُدًى لِّلْمُتَّقِينَ";

rules.forEach(rule => {
  const subText = text.substring(rule.start, rule.end);
  console.log(rule.start + " - " + rule.end + ": " + rule.rule);
  console.log(subText);
});

And here is the result

Result

Am I doing something wrong?

Thanks in advance

@cpfair
Copy link
Owner

cpfair commented Oct 4, 2021

It appears that tanzil.net has made some minor encoding changes to the text, so the indices no longer align. I have attached the original quran-uthmani.txt file I used when when generating the rule files - in shaa Allah I will look at regenerating them to match the current tanzil.net format.

quran-uthmani.txt (downloaded from Tanzil.net ca. Apr 6, 2017).

@ngekoding
Copy link
Author

ngekoding commented Oct 4, 2021

Jazaakallahu khairan, I will try to use it.

@ngekoding
Copy link
Author

Tested with 2:2 with no problem, but with 2:3 the problem still exists.

OK for 2:2

Problem for 2:3

The code still same with the above, only for the start changed as because the substring index begin from 0;

rules.forEach(rule => {
  const subText = text.substring(rule.start - 1, rule.end); // changed to: rule.start - 1
  console.log(rule.start + " - " + rule.end + ": " + rule.rule);
  console.log(subText);
});

any idea?

@ngekoding
Copy link
Author

If I use original code (without - 1 for the start), it worked for 2:3, but 2:2 got problem.

Problem

@cpfair
Copy link
Owner

cpfair commented Oct 5, 2021

Based on the reference material used in generating the rulesets, the dal is not included in that rule. E.g. http://recitequran.com/2:2 (highlights the fathatain on the dal, but not the dal itself). And, due to the way the rules are represented in this system, they can apply only to a contiguous span of codepoints (whereas in this case it may be better if it could cover two disjoint spans, as seen in the ReciteQuran link above).

@ngekoding
Copy link
Author

Thank you, so this is my misunderstanding about the implementation of the rules.

@korbav
Copy link

korbav commented Oct 7, 2021

It appears that tanzil.net has made some minor encoding changes to the text, so the indices no longer align. I have attached the original quran-uthmani.txt file I used when when generating the rule files - in shaa Allah I will look at regenerating them to match the current tanzil.net format.

quran-uthmani.txt (downloaded from Tanzil.net ca. Apr 6, 2017).

Wonderful. That could also explain the issues I raised in another comment.

I just follow the instructions, but got the wrong result.

Here is my code to extract the data

const tajweedRules = require("./tajweed.hafs.uthmani-pause-sajdah.json");

const rules = tajweedRules[8].annotations; // 2:2

const text = "ذَٰلِكَ ٱلْكِتَٰبُ لَا رَيْبَ ۛ فِيهِ ۛ هُدًى لِّلْمُتَّقِينَ";

rules.forEach(rule => {
  const subText = text.substring(rule.start, rule.end);
  console.log(rule.start + " - " + rule.end + ": " + rule.rule);
  console.log(subText);
});

And here is the result

Result

Am I doing something wrong?

Thanks in advance

I noticed you're using Javascript as well.
It seems that you really can get it working naively.
As suggested by another user it seems obligatory to take care of the sleeping marks offset to have it more or less working.
Even with that though, and maybe because the uthmani script got updated, I was unable to get the final result 100% aligned with the original books.

@ngekoding
Copy link
Author

@korbav Currently I use the tajweed version by Quran.com API. I really don’t dare to take any risks for use using this way for now.

@korbav
Copy link

korbav commented Oct 7, 2021

Quran.com API

That seems to be a great option.
This project is awesome too, and I'm sure we're really close to get a great alternative to the Quran.com API with it!

@cpfair
Copy link
Owner

cpfair commented Oct 12, 2021

That API looks nice. I've added it to the readme as a suggested alternative, given that this project hasn't been maintained in some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants