diff --git a/ac/__init__.py b/ac/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/autocorrect.py b/ac/autocorrect.py similarity index 100% rename from autocorrect.py rename to ac/autocorrect.py diff --git a/demo.py b/demo.py index 5589502..0781cc6 100644 --- a/demo.py +++ b/demo.py @@ -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: @@ -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 + "\"?") diff --git a/demo_config b/demo_config new file mode 100644 index 0000000..43cb153 --- /dev/null +++ b/demo_config @@ -0,0 +1 @@ +showallsimilarities="True" \ No newline at end of file