Skip to content

Commit

Permalink
Improve demo.py, add demo configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
LyubomirT committed Nov 26, 2023
1 parent 933f116 commit c751687
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Empty file added ac/__init__.py
Empty file.
File renamed without changes.
17 changes: 15 additions & 2 deletions demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
from main import is_correct, get_similar
from ac.autocorrect import is_correct, get_similar

def load_config():
with open("demo_config", "r") as f:
config = f.read()
return config

config = load_config()
# showallsimilarities="True"
showallsimilarities = config.split("showallsimilarities=\"")[1].split("\"")[0]

def demo():
while True:
Expand All @@ -7,9 +16,13 @@ def demo():
print("Correct!")
else:
print("Incorrect!")
similar = get_similar(word, 0.7, chunks=20, upto=5)
similar = get_similar(word, 0.5, chunks=20, upto=5)
if similar == None:
print("No similar words found.")
elif showallsimilarities == "True":
print("Did you mean any of the following?")
for w in similar:
print("\"" + w + "\"")
else:
similar = similar[0]
print("Did you mean \"" + similar + "\"?")
Expand Down
1 change: 1 addition & 0 deletions demo_config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
showallsimilarities="True"

0 comments on commit c751687

Please sign in to comment.