Spaces:
Runtime error
Runtime error
import gradio as gr | |
import rebiber | |
import os | |
import uuid | |
# Load Bib Database | |
filepath = os.path.abspath(rebiber.__file__).replace("__init__.py","") | |
bib_list_path = os.path.join(filepath, "bib_list.txt") | |
bib_db = rebiber.construct_bib_db(bib_list_path, start_dir=filepath) | |
def process(input_bib): | |
random_id = uuid.uuid4().hex | |
with open(f"input_{random_id}.bib", "w") as f: | |
f.write(input_bib.replace("\t", " ")) | |
all_bib_entries = rebiber.load_bib_file(f"input_{random_id}.bib") | |
print("# Input Bib Entries:", len(all_bib_entries)) | |
rebiber.normalize_bib(bib_db, all_bib_entries, f"output_{random_id}.bib") | |
with open(f"output_{random_id}.bib") as f: | |
output_bib = f.read().replace("\n ", "\n ") | |
# delete both files | |
# print(output_bib) | |
return output_bib | |
example_input = """ | |
@article{lin2020birds, | |
title={Birds have four legs?! NumerSense: Probing Numerical Commonsense Knowledge of Pre-trained Language Models}, | |
author={Lin, Bill Yuchen and Lee, Seyeon and Khanna, Rahul and Ren, Xiang}, | |
journal={arXiv preprint arXiv:2005.00683}, | |
year={2020} | |
} | |
""" | |
examples = [[example_input]] | |
iface = gr.Interface(fn=process, | |
inputs=gr.inputs.Textbox(lines=30, label="Input BIB"), | |
outputs=gr.outputs.Textbox(label="Output BIB").style(show_copy_button=True), | |
examples=examples, | |
allow_flagging="never" | |
) | |
if __name__ == "__main__": | |
iface.launch() | |
""" | |
@article{lin2020birds, | |
title={Birds have four legs?! NumerSense: Probing Numerical Commonsense Knowledge of Pre-trained Language Models}, | |
author={Lin, Bill Yuchen and Lee, Seyeon and Khanna, Rahul and Ren, Xiang}, | |
journal={arXiv preprint arXiv:2005.00683}, | |
year={2020} | |
} | |
@inproceedings{lin2020birds, | |
address = {Online}, | |
author = {Lin, Bill Yuchen and | |
Lee, Seyeon and | |
Khanna, Rahul and | |
Ren, Xiang}, | |
booktitle = {Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)}, | |
doi = {10.18653/v1/2020.emnlp-main.557}, | |
pages = {6862--6868}, | |
publisher = {Association for Computational Linguistics}, | |
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}, | |
url = {https://aclanthology.org/2020.emnlp-main.557}, | |
year = {2020} | |
} | |
""" |