Spaces:
Sleeping
Sleeping
Commit
·
c6dbfda
1
Parent(s):
437fb7f
feat: set up interfaces
Browse files- app.py +40 -3
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,7 +1,44 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import penman
|
3 |
|
4 |
+
def run(text, source_style):
|
5 |
+
source_amr = penman.encode("(z0 / halo)")
|
6 |
+
source_amr_display = penman.decode(source_amr)
|
7 |
+
yield source_amr_display, "...", "...", "...", "..."
|
8 |
|
9 |
+
triplets = [
|
10 |
+
("kamar", "sangat bagus", "positif"),
|
11 |
+
("kamar", "bersih", "positif")
|
12 |
+
]
|
13 |
+
triplets_display = "\n".join(f"({x[0]}, {x[1]}, {x[2]})" for x in triplets)
|
14 |
+
yield source_amr_display, triplets_display, "...", "...", "..."
|
15 |
+
|
16 |
+
style_words = ["bagus", "bersih"]
|
17 |
+
style_words_display = ", ".join(style_words)
|
18 |
+
yield source_amr_display, triplets_display, style_words_display, "...", "..."
|
19 |
+
|
20 |
+
target_amr = penman.encode("(z0 / dunia)")
|
21 |
+
target_amr_display = penman.decode(target_amr)
|
22 |
+
yield source_amr_display, triplets_display, style_words_display, target_amr_display, "..."
|
23 |
+
|
24 |
+
result = f"dunia ({text=}, {source_style=})"
|
25 |
+
yield source_amr_display, triplets_display, style_words_display, target_amr_display, result
|
26 |
+
|
27 |
+
demo = gr.Interface(
|
28 |
+
fn=run,
|
29 |
+
inputs=[
|
30 |
+
gr.Textbox(label="Teks (Text)"),
|
31 |
+
gr.Radio(label="Gaya sumber (Source style)", choices=[
|
32 |
+
("Positif (positive)", "LABEL_1"),
|
33 |
+
("Negatif (negatif)", "LABEL_0"),
|
34 |
+
]),
|
35 |
+
],
|
36 |
+
outputs=[
|
37 |
+
gr.Textbox(label="AMR graf sumber (Source AMR graph)"),
|
38 |
+
gr.Textbox(label="Triplet (Triplets)"),
|
39 |
+
gr.Textbox(label="Kata bergaya (Style words)"),
|
40 |
+
gr.Textbox(label="AMR graf target (Target AMR graph)"),
|
41 |
+
gr.Textbox(label="Hasil (Result)"),
|
42 |
+
]
|
43 |
+
)
|
44 |
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Penman==1.3.0
|