Spaces:
Runtime error
Runtime error
(Bill) Yuchen Lin
commited on
Commit
•
9269d50
1
Parent(s):
29e6077
updates
Browse files- .gitignore +1 -0
- app.py +72 -3
- flagged/log.csv +0 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
*.bib
|
app.py
CHANGED
@@ -1,9 +1,78 @@
|
|
1 |
import gradio as gr
|
2 |
import rebiber
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
|
8 |
if __name__ == "__main__":
|
9 |
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import rebiber
|
3 |
+
import os
|
4 |
+
import uuid
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
# Load Bib Database
|
9 |
+
filepath = os.path.abspath(rebiber.__file__).replace("__init__.py","")
|
10 |
+
bib_list_path = os.path.join(filepath, "bib_list.txt")
|
11 |
+
bib_db = rebiber.construct_bib_db(bib_list_path, start_dir=filepath)
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
def process(input_bib):
|
17 |
+
random_id = uuid.uuid4().hex
|
18 |
+
with open(f"input_{random_id}.bib", "w") as f:
|
19 |
+
f.write(input_bib.replace("\t", " "))
|
20 |
+
all_bib_entries = rebiber.load_bib_file(f"input_{random_id}.bib")
|
21 |
+
print("# Input Bib Entries:", len(all_bib_entries))
|
22 |
+
rebiber.normalize_bib(bib_db, all_bib_entries, f"output_{random_id}.bib")
|
23 |
+
with open(f"output_{random_id}.bib") as f:
|
24 |
+
output_bib = f.read().replace("\n ", "\n ")
|
25 |
+
# delete both files
|
26 |
+
# print(output_bib)
|
27 |
+
return output_bib
|
28 |
+
|
29 |
+
|
30 |
+
example_input = """
|
31 |
+
@article{lin2020birds,
|
32 |
+
title={Birds have four legs?! NumerSense: Probing Numerical Commonsense Knowledge of Pre-trained Language Models},
|
33 |
+
author={Lin, Bill Yuchen and Lee, Seyeon and Khanna, Rahul and Ren, Xiang},
|
34 |
+
journal={arXiv preprint arXiv:2005.00683},
|
35 |
+
year={2020}
|
36 |
+
}
|
37 |
+
"""
|
38 |
+
|
39 |
+
examples = [[example_input]]
|
40 |
+
|
41 |
+
|
42 |
+
iface = gr.Interface(fn=process,
|
43 |
+
inputs=gr.inputs.Textbox(lines=30, label="Input BIB"),
|
44 |
+
outputs=gr.outputs.Textbox(label="Output BIB").style(show_copy_button=True),
|
45 |
+
examples=examples,
|
46 |
+
allow_flagging="never"
|
47 |
+
)
|
48 |
+
|
49 |
+
|
50 |
|
|
|
51 |
|
52 |
if __name__ == "__main__":
|
53 |
iface.launch()
|
54 |
+
|
55 |
+
|
56 |
+
"""
|
57 |
+
@article{lin2020birds,
|
58 |
+
title={Birds have four legs?! NumerSense: Probing Numerical Commonsense Knowledge of Pre-trained Language Models},
|
59 |
+
author={Lin, Bill Yuchen and Lee, Seyeon and Khanna, Rahul and Ren, Xiang},
|
60 |
+
journal={arXiv preprint arXiv:2005.00683},
|
61 |
+
year={2020}
|
62 |
+
}
|
63 |
+
|
64 |
+
@inproceedings{lin2020birds,
|
65 |
+
address = {Online},
|
66 |
+
author = {Lin, Bill Yuchen and
|
67 |
+
Lee, Seyeon and
|
68 |
+
Khanna, Rahul and
|
69 |
+
Ren, Xiang},
|
70 |
+
booktitle = {Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)},
|
71 |
+
doi = {10.18653/v1/2020.emnlp-main.557},
|
72 |
+
pages = {6862--6868},
|
73 |
+
publisher = {Association for Computational Linguistics},
|
74 |
+
title = {{B}irds have four legs?! {N}umer{S}ense: {P}robing {N}umerical {C}ommonsense {K}nowledge of {P}re-{T}rained {L}anguage {M}odels},
|
75 |
+
url = {https://aclanthology.org/2020.emnlp-main.557},
|
76 |
+
year = {2020}
|
77 |
+
}
|
78 |
+
"""
|
flagged/log.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|