Spaces:
Running
Running
solve lookup_compound
Browse files
app.py
CHANGED
@@ -45,7 +45,12 @@ symspell.load_dictionary("symspell_dict_pythainlp.txt", term_index=0, count_inde
|
|
45 |
|
46 |
# แก้คำผิด
|
47 |
def correct_query_with_symspell(query: str) -> str:
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
49 |
if suggestions:
|
50 |
return suggestions[0].term
|
51 |
return query
|
|
|
45 |
|
46 |
# แก้คำผิด
|
47 |
def correct_query_with_symspell(query: str) -> str:
|
48 |
+
# ถ้า query มีคำเดียว ใช้ lookup ปกติ
|
49 |
+
if len(query.strip().split()) == 1:
|
50 |
+
suggestions = symspell.lookup(query, Verbosity.CLOSEST, max_edit_distance=2)
|
51 |
+
else:
|
52 |
+
suggestions = symspell.lookup_compound(query, 2)
|
53 |
+
|
54 |
if suggestions:
|
55 |
return suggestions[0].term
|
56 |
return query
|