Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
thai_consonants = "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรลวศษสหฬอฮ" # 44 chars
|
4 |
|
@@ -15,14 +16,19 @@ thai_tonemarks = "\u0e48\u0e49\u0e4a\u0e4b" # 4
|
|
15 |
|
16 |
all_thai = list(thai_consonants + thai_vowels)
|
17 |
|
|
|
|
|
|
|
|
|
18 |
def greet(name):
|
19 |
_temp = []
|
|
|
20 |
for i in all_thai:
|
21 |
if i not in name:
|
22 |
_temp.append(i)
|
23 |
if len(_temp)>0:
|
24 |
-
return "Not complete: "+" ".join(_temp)
|
25 |
-
return "Complete!!! :D"
|
26 |
|
27 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text",live=True)
|
28 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from pythainlp.tokenize import word_tokenize
|
3 |
|
4 |
thai_consonants = "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรลวศษสหฬอฮ" # 44 chars
|
5 |
|
|
|
16 |
|
17 |
all_thai = list(thai_consonants + thai_vowels)
|
18 |
|
19 |
+
|
20 |
+
def count_words(text):
|
21 |
+
return len(word_tokenize(text))
|
22 |
+
|
23 |
def greet(name):
|
24 |
_temp = []
|
25 |
+
_n = count_words(name)
|
26 |
for i in all_thai:
|
27 |
if i not in name:
|
28 |
_temp.append(i)
|
29 |
if len(_temp)>0:
|
30 |
+
return "Not complete: "+" ".join(_temp)+"\n\nNumber: "+str(_n)+" words"
|
31 |
+
return "Complete!!! :D"+"\n\nNumber: "+str(_n)+" words"
|
32 |
|
33 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text",live=True)
|
34 |
demo.launch()
|