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

Feedback #1

Open
wants to merge 5 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,18 @@ Exp2: Choose from options: <br />
Soundex code for "example" is E251 <br />



Step 2. TBD.
Step 2.

1. create file checker.py <br />
2. in the checker.py file write function that will map Soundex code to words of dictionary.txt file (find out best(fastest) way to implement mapping) <br />
3. in the checker.py file write function that get misspelled word, count Soundex code, get list of words that has the same Soundex code as misspelled word, count Levenstein distance between misspelled word and that list of words and return words that have minimal Levenstein distance with misspelled word. <br />
4. update main.py to work as follows: <br />

Exp.: Choose from options: <br />
1. Levenshtein <br />
2. Soundex <br />
3. Spell correction <br />
Type 1, 2 or 3: 3 <br />
Write misspelled word: sprinq <br />
Possible options: spring, sprint

26 changes: 26 additions & 0 deletions checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from utils import soundex
from utils import lev_distance
import os


def sdx_code_map():
abs_path = os.getcwd()
with open(os.path.join(abs_path, "dictionary.txt"), "r") as dict_file:
line = dict_file.readline()
stack_for_words = {}
while line:
sdx_of_word = soundex(line)
if sdx_of_word in stack_for_words:
stack_for_words[sdx_of_word].append(line[:-1])
else:
stack_for_words[sdx_of_word] = [line[:-1]]
line = dict_file.readline()
return stack_for_words


def final_words(str1):
result = sdx_code_map()
sdx_of_str1 = soundex(str1)
for key, values in result.items():
if key == sdx_of_str1:
return ",".join(word for word in values if lev_distance(str1, word) <= 2)
Loading