Giter Site home page Giter Site logo

Comments (6)

mmahalwy avatar mmahalwy commented on August 20, 2024

This MAY help!

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/fuzzy-matching.html
http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/phonetic-matching.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-phonetic-tokenfilter.html
https://github.com/elasticsearch/elasticsearch-analysis-phonetic

from quran.com-api.

ATouhou avatar ATouhou commented on August 20, 2024

If you search for : "
http://alpha.quran.com/search?q=%D8%A7%D9%84%D8%B1%D9%82%D8%A7%D8%A8
"

Then the second result have " /em> " in the search results (in mid of the arabic text)

from quran.com-api.

goz avatar goz commented on August 20, 2024

@mmahalwy is it for translation index only? how is the ES indexing works currently, I see translation index and ayah index?

from quran.com-api.

mmahalwy avatar mmahalwy commented on August 20, 2024

@ATouhou yes getting that error not sure why. @gozali currently, ES indexes these models: https://github.com/quran/quran-api-rails/blob/dev/app/models/concerns/searchable.rb#L5 in which translation is further indexed by language.

This isn't too bad, but the challenge here is that transliteration is doing a match query rather than an actual transliteration refinement and match

from quran.com-api.

mmahalwy avatar mmahalwy commented on August 20, 2024

@gozali see what @ahmedre has built:

require 'levenshtein'

def compareText(ayahtext, query)
   str = ''

   best = 0
   cutoff = 80
   minPercent = 70

   # adjust percentage for short queries against long ayahs
   factor = ayahtext.length / query.length
   if (factor > 10)
      minPercent = minPercent - (factor / 2)
   end

   val = 0
   ayah = ayahtext
   while (true)
      if ayah.length == 1
         return 0
      end
      ayah = ayah[val..-1]

      if val == 0
         val = 1
      end

      if ((ayah[0] != query[0]) and (ayah.index(query[0]) == nil))
         return best
      end

      ayah = ayah[ayah.index(query[0])..-1]
      len = [ayah.length, query.length].min
      truncated = ayah[0..len]

print 'comparing ' + query + ' vs ' + truncated + "\n"
      distance = Levenshtein.distance query, truncated
print 'got ' + distance.to_s + "\n"
      percent = 100 * (1.0 - (distance.to_f / truncated.length))
print "percent: " + percent.to_s + "\n"
      if percent > minPercent
         if percent > best
            best = percent
         end

         if best > cutoff
            return best
         end
      end
   end

   return best
end

def prepareText(str)
   return str.gsub('oo', 'u')
             .gsub('-', '')
             .downcase
             .gsub('aa', 'a')
             .gsub(' ', '')
             .gsub('ia', 'i')
             .gsub('7', 'h')
end

ayah = 'bismillahirrahmanirraheem' # from db
print compareText(ayah, prepareText('ra7man'))

We need to run this either prior to ES to find matching ayahs OR somehow add this to ES for it to use this as a scoring mechanism for Transliteration. I don't know how to do that, but I think @sharabash would have a better idea.

from quran.com-api.

mmahalwy avatar mmahalwy commented on August 20, 2024

closing this

from quran.com-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.