Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore_term_with_digits doesn't work #100

Closed
xcTorres opened this issue Nov 26, 2021 · 2 comments
Closed

ignore_term_with_digits doesn't work #100

xcTorres opened this issue Nov 26, 2021 · 2 comments

Comments

@xcTorres
Copy link

MAX_EDIT_DISTANCE = 2

address_str = '005'
suggestions = city_state_spelling_corrector.lookup_compound(address_str,
max_edit_distance=MAX_EDIT_DISTANCE,
ignore_term_with_digits=True,
transfer_casing=False)
for suggestion in suggestions:
print(str(suggestion))

Here is the output
i di

@mammothb
Copy link
Owner

mammothb commented Nov 27, 2021

Sorry about that, ignore_term_with_digits=True only works when ignore_non_words=True as well, I should have made that clearer in the documentation and print a warning if only ignore_term_with_digits=True is used.

I tried your sample input by adapting an example from the documentation and I think it managed to give the output you were originally expecting.

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"
)
# term_index is the column of the term and count_index is the
# column of the term frequency
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 = "005"
# max edit distance per lookup (per single word, not per whole input string)
suggestions = sym_spell.lookup_compound(
    input_term, max_edit_distance=2, ignore_non_words=True, ignore_term_with_digits=True
)
# display suggestion term, edit distance, and term frequency
for suggestion in suggestions:
    print(suggestion)

Output: 005, 0, 0

@xcTorres
Copy link
Author

Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants