fawazahmed0 / hadith-api

Free Hadith API Service with Multiple Languages and Multiple Grades
The Unlicense
211 stars 46 forks source link

Different number of hadiths in Urdu versions #16

Open aadimator opened 1 year ago

aadimator commented 1 year ago

When I print the length of the hadiths array, it contains different number of hadiths for the Urdu version.

print(len(data['ara']['hadiths']))
print(len(data['ara1']['hadiths']))
print(len(data['eng']['hadiths']))
print(len(data['urd']['hadiths']))

would result in

7589
7589
7589
7586

for bukhari shareef.

Why is there a discrepancy, and how can this be resolved? I'm parsing the main json files: image

Thanks.

fawazahmed0 commented 1 year ago

Why is there a discrepancy The reason for difference in length of array is because there are few hadiths missing or few extra hadiths.

You should use hadithnumber ( and not array index), when populating data. For example

        {
            "hadithnumber": 1,
            "arabicnumber": 1,
            "text": "کو حمیدی نے یہ حدیث بیان کی، انہوں نے کہا کہ ہم کو سفیان نے یہ حدیث بیان کی، وہ کہتے ہیں ہم کو یحییٰ بن سعید انصاری نے یہ حدیث بیان کی، انہوں نے کہا کہ مجھے یہ حدیث محمد بن ابراہیم تیمی سے حاصل ہوئی۔ انہوں نے اس حدیث کو علقمہ بن وقاص لیثی سے سنا، ان کا بیان ہے کہ میں نے مسجد نبوی میں منبر رسول صلی اللہ علیہ وسلم پر عمر بن خطاب رضی اللہ عنہ کی زبان سے سنا، وہ فرما رہے تھے کہ میں نے جناب رسول اللہ صلی اللہ علیہ وسلم سے سنا آپ صلی اللہ علیہ وسلم فرما رہے تھے کہ تمام اعمال کا دارومدار نیت پر ہے اور ہر عمل کا نتیجہ ہر انسان کو اس کی نیت کے مطابق ہی ملے گا۔ پس جس کی ہجرت ( ترک وطن ) دولت دنیا حاصل کرنے کے لیے ہو یا کسی عورت سے شادی کی غرض ہو۔ پس اس کی ہجرت ان ہی چیزوں کے لیے ہو گی جن کے حاصل کرنے کی نیت سے اس نے ہجرت کی ہے۔",
            "grades": [],
            "reference": {
                "book": 1,
                "hadith": 1
            }
        }
        {
            "hadithnumber": 1,
            "arabicnumber": 1,
            "text": "Narrated 'Umar bin Al-Khattab: I heard Allah's Messenger (ﷺ) saying, \"The reward of deeds depends upon the intentions and every person will get the reward according to what he has intended. So whoever emigrated for worldly benefits or for a woman to marry, his emigration was for what he emigrated for",
            "grades": [],
            "reference": {
                "book": 1,
                "hadith": 1
            }
        }
        {
            "hadithnumber": 1,
            "arabicnumber": 1,
            "text": "حَدَّثَنَا الْحُمَيْدِيُّ عَبْدُ اللَّهِ بْنُ الزُّبَيْرِ ، قَالَ : حَدَّثَنَا سُفْيَانُ ، قَالَ : حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ الْأَنْصَارِيُّ ، قَالَ : أَخْبَرَنِي مُحَمَّدُ بْنُ إِبْرَاهِيمَ التَّيْمِيُّ ، أَنَّهُ سَمِعَ عَلْقَمَةَ بْنَ وَقَّاصٍ اللَّيْثِيَّ ، يَقُولُ : سَمِعْتُ عُمَرَ بْنَ الْخَطَّابِ رَضِيَ اللَّهُ عَنْهُ عَلَى الْمِنْبَرِ، قَالَ : سَمِعْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ، يَقُولُ : \" إِنَّمَا الْأَعْمَالُ بِالنِّيَّاتِ، وَإِنَّمَا لِكُلِّ امْرِئٍ مَا نَوَى، فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى دُنْيَا يُصِيبُهَا أَوْ إِلَى امْرَأَةٍ يَنْكِحُهَا، فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ",
            "grades": [],
            "reference": {
                "book": 1,
                "hadith": 1
            }
        }

All the above are hadithnumber 1 and points to exact same hadith.

aadimator commented 1 year ago

Some Urdu hadiths are missing: image

And here's the same hadiths but in English: image

This is the case in most of the files. The last few hadiths in the urdu versions have empty text.

unkn4wn commented 1 year ago

When I print the length of the hadiths array, it contains different number of hadiths for the Urdu version.

print(len(data['ara']['hadiths']))
print(len(data['ara1']['hadiths']))
print(len(data['eng']['hadiths']))
print(len(data['urd']['hadiths']))

would result in

7589
7589
7589
7586

for bukhari shareef.

Why is there a discrepancy, and how can this be resolved? I'm parsing the main json files: image

Thanks.

All arrays in Bukhari should have the same length now. I found the issue and will fix inshaaAllah also the other books one by one.