File size: 2,320 Bytes
4e9d603
0fa757f
9269d50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4e9d603
0fa757f
 
 
9269d50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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}
}   
"""