Coder Social home page Coder Social logo

(using MySQL) How do I efficiently limit resulting dictionary candidates to only those with DamLev distance <=2? about symspell HOT 2 CLOSED

rockroland avatar rockroland commented on August 25, 2024
(using MySQL) How do I efficiently limit resulting dictionary candidates to only those with DamLev distance <=2?

from symspell.

Comments (2)

wolfgarbe avatar wolfgarbe commented on August 25, 2024

Generally, we have to calculate the Levenshtein distance ONLY for candidates that were found when deleting chars both on the input term, AND the dictionary term (deleting on both sides is required for replaces [kar->car] and adjacent transposes [acr->car] only).

Additionally, we can discard a candidate WITHOUT calculating the Levenshtein distance, if the delete positions in input term and dictionary term were on different sides of the resulting delete stem, and the number of deleted chars on both sides > maximum edit distance. But this requires that we store the delete positions together with the deletes.

Example:


[a]re
   re[do]

The sum of deleted chars is 3, the maximum edit distance is 2, the delete positions are on different sides of the stem, so we can discard the suggestion without calculating the Levenshtein distance.

SymSpell contains additional optimizations (discard candidates without Levenshtein calculation) for the case when we don't need all suggestions below a maximum edit distance (Verbosity.All), but only those candidates with the lowest edit distance (Verbosity.Top Verbosity.Closest).

from symspell.

rockroland avatar rockroland commented on August 25, 2024

That makes sense. Thanks for the clear answer.. now I can proceed with confidence. Best Regards

from symspell.

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.