import subprocess import gradio as gr EXAMPLE_INPUT = """@inproceedings{li-etal-2019-survey, title = "A Sophisticated Survey about Chinese Poem and Beers", author = "Li, Bai and Ha, Pi and Jin, Shibai and Xue, Hua and Mao, Tai", booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)", month = nov, year = "2019", address = "Hong Kong, China", publisher = "Association for Computational Linguistics", url = "https://aclanthology.org/D19-1214", doi = "10.18653/v1/D19-1214", pages = "2078--2087", abstract = "Intent detection and slot filling are two main tasks for building a spoken language understanding (SLU) system. The two tasks are closely tied and the slots often highly depend on the intent. In this paper, we propose a novel framework for SLU to better incorporate the intent information, which further guiding the slot filling. In our framework, we adopt a joint model with Stack-Propagation which can directly use the intent information as input for slot filling, thus to capture the intent semantic knowledge. In addition, to further alleviate the error propagation, we perform the token-level intent detection for the Stack-Propagation framework. Experiments on two publicly datasets show that our model achieves the state-of-the-art performance and outperforms other previous methods by a large margin. Finally, we use the Bidirectional Encoder Representation from Transformer (BERT) model in our framework, which further boost our performance in SLU task.", }""" def sim_biber(references: str, keep_keys: str) -> list[str]: with open("input.txt", "w") as f: f.write(references) with open("keep_keys.cfg", "w") as f: f.write(keep_keys) result = subprocess.run( "simbiber -i input.txt -o output.txt", shell=True, capture_output=True, text=True, ) if result.returncode == 0: with open("output.txt", "r") as f: output = f.read() return output, result.stdout else: return "", result.stderr demo = gr.Interface( fn=sim_biber, inputs=[ gr.Textbox(label="References to be simplified", value=EXAMPLE_INPUT, lines=16), gr.Textbox(label="Keep keys", value="booktitle,pages,journal"), ], outputs=[ gr.Textbox(label="Simplified References"), gr.Textbox(label="Command Line Output"), ], title="SimBiber", description="A tool to simplify bibtex references using SimBiber. Visit https://github.com/MLNLP-World/SimBiber for more information.", ) demo.launch()