Spaces:
Sleeping
Sleeping
File size: 1,554 Bytes
80d83c6 e7b65e8 4fb5c2c 031794e 4fb5c2c 80d83c6 996ca56 dbd752a 9fcd8a5 dbd752a baa69dc f95a383 bc1e093 f95a383 dbd752a 188a21d 23a5c8d 188a21d 904463c 80d83c6 207d7a5 e5d6a80 e660a3f e5d6a80 e660a3f e5d6a80 207d7a5 e5d6a80 67b9a61 207d7a5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import gradio as gr
import subprocess, time
subprocess.run(['git', 'clone', 'https://github.com/olpa/camxes-py', 'camxes_py'])
time.sleep(3)
import camxes_py.camxes_py as camxes
#import camxes_py.camxes_py.parsers.camxes_ilmen as camxes_ilmen
from camxes_py.camxes_py.parsers import camxes_ilmen
from camxes_py.camxes_py.transformers import minimal
parser = camxes_ilmen.Parser(None)
minimal_transformer = minimal.Transformer()
def parse(lojban):
"""
Parse the Lojban text and convert it to a textual parse tree. If the input is invalid, the output will be "[NOT PARSEABLE]".
Args:
lojban: string;
Returns:
Tuple of (structured_lojban) where structured_lojban is the semantic structure
"""
text, node = camxes.match(lojban, parser, None, minimal_transformer, True)
if text is None:
text = '[NOT PARSEABLE]'
return str(text)
default_input = "coi rodo"
input_textbox = gr.Textbox(
label="Lojban Text",
#info="ignores: emojis, emoticons, numbers, URLs",
lines=3,
value=default_input,
autofocus=True
)
parse_tree = gr.Label(
label="Parse Tree",
# could not auto select example output
value="['free', [['COI', 'coi'], ['sumti_5', [['PA', 'ro'], ['KOhA', 'do']]]]]"
)
gradio_app = gr.Interface(
parse,
[
input_textbox,
],
outputs=parse_tree,
#examples=[
# ["coi rodo"],
#],
cache_examples=True,
live=True,
title="Lojban Parser",
)
gradio_app.launch(show_api=True, show_error=True, mcp_server=True) |