fawazahmed0 / hadith-api

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

Further partition the text of hadith #19

Open GibreelAbdullah opened 1 year ago

GibreelAbdullah commented 1 year ago

Further partition the text of hadith.

Have a look at this - https://us-west1-hadeeth.cloudfunctions.net/hadith/bukhari/2

This api has further partitioned the text of the Hadith as Prefix (containing the chain of narrations), Post-fix (Comment by the narrator).

This would help in better parsing of data.

GibreelAbdullah commented 1 year ago

Just to add, I have a local DB which contains all the additional data as seen in the API. If this make sense I can work on this.

fawazahmed0 commented 1 year ago

Thanks @GibreelAbdullah , I checked the link, it seems that the data is in arabic only, my API is for different translations. Anyways, if possible you can share the DB file here, I will look into it later.

Update: 10-09-22 backup for this post

GibreelAbdullah commented 1 year ago

Yeah, my goal was to create an API similar to yours. Was about to add the English translations today but stumbled upon your repo.

Since you are already ahead in your work, I would rather contribute here than reinvent the wheel.

InShaAllah i will upload the DB file in some time.

GibreelAbdullah commented 1 year ago

https://github.com/GibreelAbdullah/HadithDBToFirestore/blob/master/hadith.zip

hadith.db file - A sqlite database file. Zipped because file size was too big.

Overview of tables -

  1. collection - Collections info (Bukhari/Muslim/AbuDawud etc)
  2. book - Books in individual collection (Book of Purification etc)
  3. chapter - individual chapters in the books
  4. hadith - Hadith in arabic
  5. hadith_en - Hadith in english
  6. scholar - Narrators in chain of narration (referenced by narrators column in hadith table)

Rest all tables are auto generated by sqlite to enable FullTextSearch

GibreelAbdullah commented 1 year ago

Assalamualekum,

In the Database/originals folder there are a lot file with "scrapped" postfix in the name of the txt files. What are they used for?

Also there are a couple of translations for urdu for example urduabudawud and urd-abudawud which are almost identical. Kindly let me know their purpose.

fawazahmed0 commented 1 year ago

You can ignore that folder, the main files are at database/linebyline folder. Database/original is used to store backup of original files(i.e the original text file before importing data)

GibreelAbdullah commented 5 months ago

Hi, We can partition the hadith text with a zero width space character. (https://www.compart.com/en/unicode/U+200B)

This way the current api can be updated without any breaking or visible changes. But for those who need it, they can partition the hadith into pre-text, text and post-text.

For example.

حَدَّثَنَا آدَمُ بْنُ أَبِي إِيَاسٍ، قَالَ حَدَّثَنَا شُعْبَةُ، عَنْ عَبْدِ اللَّهِ بْنِ أَبِي السَّفَرِ، وَإِسْمَاعِيلَ، عَنِ الشَّعْبِيِّ، عَنْ عَبْدِ اللَّهِ بْنِ عَمْرٍو ـ رضى الله عنهما ـ عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏ "‏ الْمُسْلِمُ مَنْ سَلِمَ الْمُسْلِمُونَ مِنْ لِسَانِهِ وَيَدِهِ، وَالْمُهَاجِرُ مَنْ هَجَرَ مَا نَهَى اللَّهُ عَنْهُ ‏"‏‏.‏ قَالَ أَبُو عَبْدِ اللَّهِ وَقَالَ أَبُو مُعَاوِيَةَ حَدَّثَنَا دَاوُدُ عَنْ عَامِرٍ قَالَ سَمِعْتُ عَبْدَ اللَّهِ عَنِ النَّبِيِّ صلى الله عليه وسلم‏.‏ وَقَالَ عَبْدُ الأَعْلَى عَنْ دَاوُدَ عَنْ عَامِرٍ عَنْ عَبْدِ اللَّهِ عَنِ النَّبِيِّ صلى الله عليه وسلم‏.‏

This will become.

حَدَّثَنَا آدَمُ بْنُ أَبِي إِيَاسٍ، قَالَ حَدَّثَنَا شُعْبَةُ، عَنْ عَبْدِ اللَّهِ بْنِ أَبِي السَّفَرِ، وَإِسْمَاعِيلَ، عَنِ الشَّعْبِيِّ، عَنْ عَبْدِ اللَّهِ بْنِ عَمْرٍو ـ رضى الله عنهما ـ عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏[ZERO WIDTH CHARACTER HERE]"‏ الْمُسْلِمُ مَنْ سَلِمَ الْمُسْلِمُونَ مِنْ لِسَانِهِ وَيَدِهِ، وَالْمُهَاجِرُ مَنْ هَجَرَ مَا نَهَى اللَّهُ عَنْهُ ‏"‏‏ ‏[ZERO WIDTH CHARACTER HERE].‏ قَالَ أَبُو عَبْدِ اللَّهِ وَقَالَ أَبُو مُعَاوِيَةَ حَدَّثَنَا دَاوُدُ عَنْ عَامِرٍ قَالَ سَمِعْتُ عَبْدَ اللَّهِ عَنِ النَّبِيِّ صلى الله عليه وسلم‏.‏ وَقَالَ عَبْدُ الأَعْلَى عَنْ دَاوُدَ عَنْ عَامِرٍ عَنْ عَبْدِ اللَّهِ عَنِ النَّبِيِّ صلى الله عليه وسلم‏.‏

fawazahmed0 commented 5 months ago

Great idea!