abdiharyadi's picture
style: add default value for source style
c446280
raw
history blame
1.58 kB
import gradio as gr
import penman
def run(text, source_style):
source_amr = penman.decode("(z0 / halo)")
source_amr_display = penman.encode(source_amr)
yield source_amr_display, "...", "...", "...", "..."
triplets = [
("kamar", "sangat bagus", "positif"),
("kamar", "bersih", "positif")
]
triplets_display = "\n".join(f"({x[0]}, {x[1]}, {x[2]})" for x in triplets)
yield source_amr_display, triplets_display, "...", "...", "..."
style_words = ["bagus", "bersih"]
style_words_display = ", ".join(style_words)
yield source_amr_display, triplets_display, style_words_display, "...", "..."
target_amr = penman.decode("(z0 / dunia)")
target_amr_display = penman.encode(target_amr)
yield source_amr_display, triplets_display, style_words_display, target_amr_display, "..."
result = f"dunia ({text=}, {source_style=})"
yield source_amr_display, triplets_display, style_words_display, target_amr_display, result
demo = gr.Interface(
fn=run,
inputs=[
gr.Textbox(label="Teks (Text)"),
gr.Radio(label="Gaya sumber (Source style)", choices=[
("Positif (Positive)", "LABEL_1"),
("Negatif (Negative)", "LABEL_0"),
], value="LABEL_1"),
],
outputs=[
gr.Textbox(label="Graf AMR sumber (Source AMR graph)"),
gr.Textbox(label="Triplet (Triplets)"),
gr.Textbox(label="Kata bergaya (Style words)"),
gr.Textbox(label="Graf AMR target (Target AMR graph)"),
gr.Textbox(label="Hasil (Result)"),
]
)
demo.launch()