项目作者: MighTguY

项目描述 :
Java port of SymSpell: 1 million times faster through Symmetric Delete spelling correction algorithm
高级语言: Java
项目地址: git://github.com/MighTguY/customized-symspell.git
创建时间: 2019-11-05T06:10:05Z
项目社区:https://github.com/MighTguY/customized-symspell

开源协议:MIT License

下载


Travis Build Status
Coverage Status
License: MIT
Maven Central
javadoc.io

Customized SymSpell SpellCheck Java

This customized spell check is is based on the spell correction fuzzy search library SymSpell with a few customizations and optimizations

Java Ported v6.6 (Bigrams)

  • the optional bigram dictionary in order to use sentence level context information for selecting best spelling correction.

SymSpell

  • The Symmetric Delete spelling correction algorithm reduces the complexity of edit candidate generation and dictionary lookup for a given Damerau-Levenshtein distance.
  • It is six orders of magnitude faster (than the standard approach with deletes + transposes + replaces + inserts) and language independent.
  • Opposite to other algorithms only deletes are required, no transposes + replaces + inserts. Transposes + replaces + inserts of the input term are transformed into deletes of the dictionary term.
  • The speed comes from the inexpensive delete-only edit candidate generation and the pre-calculation.

Customizations

  • We replaced the Damerau-Levenshtein implementation with a weighted Damerau-Levenshtein implementation: where each operation (delete, insert, swap, replace) can have different edit weights.
  • We added some customizing “hooks” that are used to rerank the top-k results (candidate list). The results are then reordered based on a combined proximity
    • added keyboard-distance to get a dynamic replacement weight (since letters close to each other are more likely to be replaced)
    • do some query normalization before search

Keyboard based Qwerty/Qwertz Distance

There are 2 implementations of the keyboards one is English Qwerty based and other is German Qwertz based implementation
we used the adjancey graph of the keyboard for the weights to the connected nodes.

Example

  1. For 2 terms:
  2. slices
  3. olives
  4. If the misspelled word is, slives
  5. both slices and olives is 1 edit distnace,
  6. so in default case the one with higher frequency will end up in the result.
  7. While with the qwerty based char distance,
  8. slives is more closer to slices.
  9. The reason for this is in Qwerty Based Keyboard,
  10. S and O are too far while V and C are adjacent.

Generation of Deletes

Word deletes are generated with taking edit distance which is minimum of max edit distance and 0.3 * word.length

Usage

Solr Usage

Accuracy Summary

Indexed Docs: 3695

Searches: 8060

Spellcorrection Strategy Accuracy Failures TP TN FP FN
LUCENE 78.96% 21.04% 5883 481 146 1550
Vanilla SymSpell 88.80% 11.20% 6888 269 358 545
Weighted SymSpell 75.74% 24.26% 5781 324 303 1652
Qwerty Vanilla SymSpell 88.57% 11.43% 6860 279 348 573
Qwerty Weighted SymSpell 75.36% 24.64% 5744 330 297 1689

Benchmark Summary

We have done 3 runs each for 30k and 80k data set, which also includes results for each verbosity level.
After the runs the final benchmarking looks like:

  1. Average Precalculation time instance 30843.33 ms
  2. Average Lookup time instance 138141.09296296295 ns ~ 0.03814 ms
  3. Total Lookup results instance 648092

More Detailed summary

Built With

Versioning

We use SemVer for versioning.

Nexus

Licenese

  1. The MIT License (MIT)
  2. Copyright © 2019 Lucky Sharma ( https://github.com/MighTguY/customized-symspell )
  3. Copyright © 2018 Wolf Garbe (Original C# implementation https://github.com/wolfgarbe/SymSpell )
  4. Permission is hereby granted, free of charge, to any person
  5. obtaining a copy of this software and associated documentation files
  6. (the Software”), to deal in the Software without restriction,
  7. including without limitation the rights to use, copy, modify,
  8. merge, publish, distribute, sublicense, and/or sell copies of
  9. the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall
  12. be included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED AS IS”, WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  16. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  17. DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  18. OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
  19. THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Special Mentions

Sachin Lala