sibthinon commited on
Commit
14cda9a
·
verified ·
1 Parent(s): 5e7c746

solve lookup_compound

Browse files
Files changed (1) hide show
  1. app.py +6 -1
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
- suggestions = symspell.lookup_compound(query, Verbosity.CLOSEST, max_edit_distance=2)
 
 
 
 
 
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