Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +46 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import typing
|
3 |
+
from NDETCStemmer import NDETCStemmer
|
4 |
+
|
5 |
+
num_text_process_limit = 100
|
6 |
+
markdown_top_info = """
|
7 |
+
# [NDETCStemmer](https://huggingface.co/kaenova/NDETCStemmer) spaces
|
8 |
+
Easily use the model with huggingface π€ and gradio interface!
|
9 |
+
Call by API is also available. Check the bottom of the page on 'Use via API π'
|
10 |
+
"""
|
11 |
+
|
12 |
+
stemmer = NDETCStemmer()
|
13 |
+
|
14 |
+
|
15 |
+
def process_single_text(text_input: "str"):
|
16 |
+
# Split input
|
17 |
+
if text_input.strip() == "":
|
18 |
+
return ""
|
19 |
+
results = stemmer.stem(text_input)
|
20 |
+
return results
|
21 |
+
|
22 |
+
with gr.Blocks() as demo:
|
23 |
+
gr.Markdown(markdown_top_info)
|
24 |
+
|
25 |
+
# Single Input
|
26 |
+
with gr.Column():
|
27 |
+
input_text = gr.Textbox(
|
28 |
+
label="Input Text",
|
29 |
+
info=f"Text to stem.",
|
30 |
+
lines=5,
|
31 |
+
value="""bibirnya memerah tangannya jadi selengket madu dan boleh saya memerah lembu ini""",
|
32 |
+
)
|
33 |
+
single_text_button = gr.Button("Stem!")
|
34 |
+
results_text = gr.Textbox(
|
35 |
+
label="Result",
|
36 |
+
interactive=False,
|
37 |
+
)
|
38 |
+
single_text_button.click(
|
39 |
+
process_single_text,
|
40 |
+
inputs=[input_text],
|
41 |
+
outputs=[results_text],
|
42 |
+
api_name="process_single_text",
|
43 |
+
)
|
44 |
+
|
45 |
+
if __name__ == "__main__":
|
46 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio==3.26.0
|
2 |
+
fastapi>0.95
|
3 |
+
NDETCStemmer-kaenova
|