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)