Code Monkey home page Code Monkey logo

Comments (4)

xcTorres avatar xcTorres commented on June 14, 2024 1

Thanks for your reply, and thanks for the package.

from symspellpy.

mammothb avatar mammothb commented on June 14, 2024

I believe this is because I missed updating replaced_words when a combination of 2 terms is the best match. I have pushed a fix to this branch. Could you please test and see if that fixes the problem for you?

I have tried it on my side with following code

import pkg_resources

from symspellpy import SymSpell

sym_spell = SymSpell(max_dictionary_edit_distance=2, prefix_length=7)
dictionary_path = pkg_resources.resource_filename(
    "symspellpy", "frequency_dictionary_en_82_765.txt"
)
bigram_path = pkg_resources.resource_filename(
    "symspellpy", "frequency_bigramdictionary_en_243_342.txt"
)
sym_spell.load_dictionary(dictionary_path, term_index=0, count_index=1)
sym_spell.load_bigram_dictionary(bigram_path, term_index=0, count_index=2)

input_term = (
    "whereis th elove GPS hehad dated forImuch of thepast who "
    "couqdn'tread in sixtgrade and 16 microstru cture him"
)
suggestions = sym_spell.lookup_compound(
    input_term, max_edit_distance=1, ignore_non_words=True
)
for suggestion in suggestions:
    print(suggestion)

for k, v in sym_spell.replaced_words.items():
    print(f"origin: {k}, modify: {v.term}, edit_distance: {v.distance}")

and managed to get the following output

where is the love GPS he had dated for much of the past who couldn't read in six grade and 16 microstructure him, 9, 0
<omitted>
origin: microstru, modify: microstructure, edit_distance: 1

and it seems to address the issue

from symspellpy.

xcTorres avatar xcTorres commented on June 14, 2024

Thanks. It works. Could I add one more question? Is there a way to get the start, end index of the origin word?

from symspellpy.

mammothb avatar mammothb commented on June 14, 2024

Unfortunately there's no way to do that in symspellpy right now, you'll have to implement some custom post processing functions in your project for that

from symspellpy.

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.