init
Browse files- app.py +56 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import subprocess
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
EXAMPLE_INPUT = """@inproceedings{li-etal-2019-survey,
|
6 |
+
title = "A Sophisticated Survey about Chinese Poem and Beers",
|
7 |
+
author = "Li, Bai and
|
8 |
+
Ha, Pi and
|
9 |
+
Jin, Shibai and
|
10 |
+
Xue, Hua and
|
11 |
+
Mao, Tai",
|
12 |
+
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)",
|
13 |
+
month = nov,
|
14 |
+
year = "2019",
|
15 |
+
address = "Hong Kong, China",
|
16 |
+
publisher = "Association for Computational Linguistics",
|
17 |
+
url = "https://aclanthology.org/D19-1214",
|
18 |
+
doi = "10.18653/v1/D19-1214",
|
19 |
+
pages = "2078--2087",
|
20 |
+
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.",
|
21 |
+
}"""
|
22 |
+
|
23 |
+
|
24 |
+
def sim_biber(references: str, keep_keys: str) -> list[str]:
|
25 |
+
with open("input.txt", "w") as f:
|
26 |
+
f.write(references)
|
27 |
+
with open("keep_keys.cfg", "w") as f:
|
28 |
+
f.write(keep_keys)
|
29 |
+
result = subprocess.run(
|
30 |
+
"simbiber -i input.txt -o output.txt",
|
31 |
+
shell=True,
|
32 |
+
capture_output=True,
|
33 |
+
text=True,
|
34 |
+
)
|
35 |
+
if result.returncode == 0:
|
36 |
+
with open("output.txt", "r") as f:
|
37 |
+
output = f.read()
|
38 |
+
return output, result.stdout
|
39 |
+
else:
|
40 |
+
return "", result.stderr
|
41 |
+
|
42 |
+
|
43 |
+
demo = gr.Interface(
|
44 |
+
fn=sim_biber,
|
45 |
+
inputs=[
|
46 |
+
gr.Textbox(label="References to be simplified", value=EXAMPLE_INPUT, lines=16),
|
47 |
+
gr.Textbox(label="Keep keys", value="booktitle,pages,journal"),
|
48 |
+
],
|
49 |
+
outputs=[
|
50 |
+
gr.Textbox(label="Simplified References"),
|
51 |
+
gr.Textbox(label="Command Line Output"),
|
52 |
+
],
|
53 |
+
title="SimBiber",
|
54 |
+
description="A tool to simplify bibtex references using SimBiber.",
|
55 |
+
)
|
56 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
git+https://github.com/MLNLP-World/Simbiber.git#egg=Simbiber
|