Code Monkey home page Code Monkey logo

Comments (3)

mammothb avatar mammothb commented on May 17, 2024

It determines the content in _deletes dictionary. The keys are the edit candidates generated by only deletes which are within an edit distance of 1 to max_edit_distance_dictionary of the original words. The dictionary values are lists of suggested correction words.

For example, with a max_edit_distance_dictionary = 1, _deletes contains

'{te': ['the'], 'he': ['the'], 'the': ['the'], 'th': ['the']}

and when max_edit_distance_dictionary = 2, _deletes contains

'h': ['the'], 'e': ['the'], 'he': ['the'], 'th': ['the'], 't': ['the'], 'te': ['the'],
'the': ['the']}

"h", "e" and "t" were not previously included since they can only be obtained by making 2 deletes (edits) from the original word "the".

prefix_length also plays a part in generating _deletes since it limits the "original word" from which we make deletes. For example, when prefix_length = 7, "unhpi" can be mapped to "unhappiness" since it's 2 deletes from "unhappi".

So we enforce max_edit_distance <= max_edit_distance_dictionary since _deletes will contain any mapping with an edit distance greater then max_edit_distance_dictionary. There was also a mistake in _edits_prefix(),

if len(key) > self._max_dictionary_edit_distance:

should have been

if len(key) > self._prefix_length:

I'm sorry if that caused this confusion.

from symspellpy.

bastia0321 avatar bastia0321 commented on May 17, 2024

Thanks, it is very clear now. So _edits_prefix() will be fixed in the later version, right?

from symspellpy.

mammothb avatar mammothb commented on May 17, 2024

The changes has been pushed to the dev branch, I'll merge it to master later. Interestingly, it does not seem to affect the accuracy of the program since having a stop index larger then the string length is handled gracefully in python. For example

s = "abc"
print(s[: 10])

gives

abc

which is what _edits_prefix() wanted.

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.