waleedkadous / ansari-backend

Ansari is a helper for you to become a better Muslim
65 stars 12 forks source link

Search results in tools/search_quran.py might not have `text` in the response #20

Closed abdullah-alnahas closed 3 months ago

abdullah-alnahas commented 4 months ago

This line caused an error when I tried to run generate-answers.ipynb notebook. It happened when this question: "Qur'an,Which of the following is Ayat Ul Kursi?,"2:255, 2:286, 2:202, 2:153",2:255" was being answered. The search request payload is: {'query': 'Ayat Ul Kursi', 'numResults': 10, 'getText': 1}. All the search results except the first have the text key as part of the ayah. Here is the request sent for reference:

import requests
headers = {'x-api-key': "kalimat_api_key"}
payload = {'query': 'Ayat Ul Kursi', 'numResults': 10, 'getText': 1}

response = requests.get('https://api.kalimat.dev/search', headers=headers, params=payload)

if response.status_code != 200:
    raise Exception(f'Request failed with status {response.status_code}')

print(response.json())

The resutls are:

[{'id': '2:255', 'navigational': 1, 'type': 'quran_verse'}, {'en_text': 'Alif-Lãm-Ra. These are the verses of the clear Book.', 'id': '12:1', 'text': 'الٓر ۚ تِلْكَ ءَايَـٰتُ ٱلْكِتَـٰبِ ٱلْمُبِينِ', 'type': 'quran_verse'}, {'en_text': '˹It is˺ a Book whose verses are perfectly explained—a Quran in Arabic for people who know,', 'id': '41:3', 'text': 'كِتَـٰبٌ فُصِّلَتْ ءَايَـٰتُهُۥ قُرْءَانًا عَرَبِيًّا لِّقَوْمٍۢ يَعْلَمُونَ', 'type': 'quran_verse'}, {'en_text': 'These are the verses of the Book, rich in wisdom.', 'id': '31:2', 'text': 'تِلْكَ ءَايَـٰتُ ٱلْكِتَـٰبِ ٱلْحَكِيمِ', 'type': 'quran_verse'}, {'en_text': 'These are the verses of the clear Book.', 'id': '28:2', 'text': 'تِلْكَ ءَايَـٰتُ ٱلْكِتَـٰبِ ٱلْمُبِينِ', 'type': 'quran_verse'}, {'en_text': 'These are the verses of the clear Book.', 'id': '26:2', 'text': 'تِلْكَ ءَايَـٰتُ ٱلْكِتَـٰبِ ٱلْمُبِينِ', 'type': 'quran_verse'}, {'en_text': 'Alif-Lãm-Ra. These are the verses of the Book, rich in wisdom.', 'id': '10:1', 'text': 'الٓر ۚ تِلْكَ ءَايَـٰتُ ٱلْكِتَـٰبِ ٱلْحَكِيمِ', 'type': 'quran_verse'}, {'en_text': 'Alif-Lãm-Ra. These are the verses of the Book; the clear Quran.', 'id': '15:1', 'text': 'الٓر ۚ تِلْكَ ءَايَـٰتُ ٱلْكِتَـٰبِ وَقُرْءَانٍۢ مُّبِينٍۢ', 'type': 'quran_verse'}, {'en_text': 'Alif-Lãm-Ra. ˹This is˺ a Book whose verses are well perfected and then fully explained. ˹It is˺ from the One ˹Who is˺ All-Wise, All-Aware.', 'id': '11:1', 'text': 'الٓر ۚ كِتَـٰبٌ أُحْكِمَتْ ءَايَـٰتُهُۥ ثُمَّ فُصِّلَتْ مِن لَّدُنْ حَكِيمٍ خَبِيرٍ', 'type': 'quran_verse'}, {'en_text': 'Ṭâ-Sĩn. These are the verses of the Quran; the clear Book.', 'id': '27:1', 'text': 'طسٓ ۚ تِلْكَ ءَايَـٰتُ ٱلْقُرْءَانِ وَكِتَابٍۢ مُّبِينٍ', 'type': 'quran_verse'}]

Please note the first result; it doesn't have text.

abdullah-alnahas commented 3 months ago

The issue has been addressed in Pull Request #18. Closing.