Alfanous-team / alfanous

Alfanous is an Arabic search engine API provides the simple and advanced search in Quran , more features and many interfaces...
http://www.alfanous.org/
GNU Affero General Public License v3.0
263 stars 89 forks source link

How to get the words number of matches (nb_matches) in the search range not in all Quran #534

Open iTarek opened 3 years ago

iTarek commented 3 years ago

When search with two words like آدم + وزوجك The results are 2 ayah from Al Bakrah sura The total words matches in the search range is 4, two in each ayah

[ وَيَا آدَمُ اسْكُنْ أَنْتَ وَزَوْجُكَ الْجَنَّةَ فَكُلَا مِنْ حَيْثُ شِئْتُمَا وَلَا تَقْرَبَا هَذِهِ الشَّجَرَةَ فَتَكُونَا مِنَ الظَّالِمِينَ ]

[ وَقُلْنَا يَا آدَمُ اسْكُنْ أَنْتَ وَزَوْجُكَ الْجَنَّةَ وَكُلَا مِنْهَا رَغَدًا حَيْثُ شِئْتُمَا وَلَا تَقْرَبَا هَذِهِ الشَّجَرَةَ فَتَكُونَا مِنَ الظَّالِمِينَ ]

I get in the API "nb_matches": 22 And I can not find any number representing the nb_matches in that search range, I can not get the number that representing the words you highlight.

This is important, Why? because when you search for word like رحمة in one sura and try to compare it with another word like عذاب in the same sura, you get the number of matches from the all Quran and you have to count the words yourself in the search range witch is one sura to get the match number in your search range.

And there are many examples how this is so important.

      },
      "words":{
         "global": {
        "nb_vocalizations": 3,
        "nb_matches": 22,
        "nb_words": 2
      },
      "interval":{
         "page":1,
         "end":2,
         "nb_pages":1,
         "total":2,
         "start":1
      }

Thank you and I wish there is already a way to get the nb_matches for words that you already highlight on my search range not in all Quran.

iTarek commented 3 years ago

I suggest you add "nb_matches_search": in the "individual": for each word, this number tell the number of matches on the search scope.

  "words": {
      "individual": {
        "1": {
          "derivations_extra": [],
          "romanization": null,
          "nb_derivations_extra": 0,
          "nb_synonyms": 0,
          "synonyms": [],
          "nb_matches": 2,
          "lemma": null,
          "vocalizations": [
            "وَزَوْجُكَ"
          ],
          "nb_ayas": 2,
          "nb_vocalizations": 1,
          "nb_derivations": 0,
          "root": null,
          "word": "وزوجك",
          "derivations": []
        },
        "2": {
          "derivations_extra": [],
          "romanization": null,
          "nb_derivations_extra": 0,
          "nb_synonyms": 0,
          "synonyms": [],
          "nb_matches": 20,
          "lemma": "آدم",
          "vocalizations": [
            "آدَمَ",
            "آدَمُ"
          ],
          "nb_ayas": 20,
          "nb_vocalizations": 2,
          "nb_derivations": 2,
          "root": "آدم",
          "word": "آدم",
          "derivations": [
            "لآدم",
            "آدم"
          ]
        }

also on the

    "words":{
         "global": {

you add the same value for the sum of "nb_matches_search": in all words

ghost commented 3 years ago

I prefer to solve the facets all the same way, I will give it a shot in the weekend