wannaphong commited on
Commit
1bc58c6
·
1 Parent(s): b9def7b

Update code

Browse files
Files changed (3) hide show
  1. routers/soundex.py +3 -3
  2. routers/spell.py +16 -0
  3. routers/tokenize.py +3 -3
routers/soundex.py CHANGED
@@ -16,13 +16,13 @@ class SoundexEngine(str, Enum):
16
 
17
 
18
  @router.post('/soundex')
19
- def soundex(text: str, engine: SoundexEngine = "udom83"):
20
  """
21
  This api converts Thai text into phonetic code.
22
 
23
  ## Input
24
 
25
- = **text**: A word that want into phonetic code.
26
  - **engine**: Soundex Engine (default is udom83)
27
  """
28
- return {"soundex": py_soundex(text=text, engine=engine)}
 
16
 
17
 
18
  @router.post('/soundex')
19
+ def soundex(word: str, engine: SoundexEngine = "udom83"):
20
  """
21
  This api converts Thai text into phonetic code.
22
 
23
  ## Input
24
 
25
+ - **word**: A word that want into phonetic code.
26
  - **engine**: Soundex Engine (default is udom83)
27
  """
28
+ return {"soundex": py_soundex(text=word, engine=engine)}
routers/spell.py CHANGED
@@ -25,8 +25,24 @@ router = APIRouter()
25
 
26
  @router.post('/correct', response_model=CorrectResponse)
27
  def correct(word: float, engine: CorrectEngine = "pn"):
 
 
 
 
 
 
 
 
28
  return {"word": py_correct(word, engine=engine)}
29
 
30
  @router.post('/spell', response_model=SpellResponse)
31
  def spell(word: float, engine: SpellEngine = "pn"):
 
 
 
 
 
 
 
 
32
  return {"word": py_spell(word, engine=engine)}
 
25
 
26
  @router.post('/correct', response_model=CorrectResponse)
27
  def correct(word: float, engine: CorrectEngine = "pn"):
28
+ """
29
+ Corrects the spelling of the given word by returning the correctly spelled word.
30
+
31
+ ## Input
32
+
33
+ - **word**: A word that want corrects the spelling of the given word.
34
+ - **engine**: Correct Engine (default is pn)
35
+ """
36
  return {"word": py_correct(word, engine=engine)}
37
 
38
  @router.post('/spell', response_model=SpellResponse)
39
  def spell(word: float, engine: SpellEngine = "pn"):
40
+ """
41
+ Provides a list of possible correct spellings of the given word. The list of words are from the words in the dictionary that incurs an edit distance value of 1 or 2. The result is a list of words sorted by their occurrences in the spelling dictionary in descending order.
42
+
43
+ ## Input
44
+
45
+ - **word**: A word that want to check spell.
46
+ - **engine**: Spell Engine (default is pn)
47
+ """
48
  return {"word": py_spell(word, engine=engine)}
routers/tokenize.py CHANGED
@@ -46,7 +46,7 @@ def word_tokenize(text: str, engine: WordTokenizeEngine = "newmm"):
46
 
47
  ## Input
48
 
49
- = **text**: Text that want to tokenize.
50
  - **engine**: Word Tokenize Engine (default is newmm)
51
  """
52
  return {"words": py_word_tokenize(text=text, engine=engine)}
@@ -59,7 +59,7 @@ def subword_tokenize(text: str, engine: SubwordTokenizeEngine = "tcc"):
59
 
60
  ## Input
61
 
62
- = **text**: Text that want to tokenize.
63
  - **engine**: Sub word Tokenize Engine (default is tcc)
64
  """
65
  return {"subwords": py_subword_tokenize(text=text, engine=engine)}
@@ -72,7 +72,7 @@ def sent_tokenize(text: str, engine: SentTokenizeEngine = "crfcut"):
72
 
73
  ## Input
74
 
75
- = **text**: Text that want to tokenize.
76
  - **engine**: Sentence Tokenize Engine (default is crfcut)
77
  """
78
  return {"sents": py_sent_tokenize(text=text, engine=engine)}
 
46
 
47
  ## Input
48
 
49
+ - **text**: Text that want to tokenize.
50
  - **engine**: Word Tokenize Engine (default is newmm)
51
  """
52
  return {"words": py_word_tokenize(text=text, engine=engine)}
 
59
 
60
  ## Input
61
 
62
+ - **text**: Text that want to tokenize.
63
  - **engine**: Sub word Tokenize Engine (default is tcc)
64
  """
65
  return {"subwords": py_subword_tokenize(text=text, engine=engine)}
 
72
 
73
  ## Input
74
 
75
+ - **text**: Text that want to tokenize.
76
  - **engine**: Sentence Tokenize Engine (default is crfcut)
77
  """
78
  return {"sents": py_sent_tokenize(text=text, engine=engine)}