Skip to content

Commit

Permalink
fix potential errors in _to_bib_item when parsing the url field
Browse files Browse the repository at this point in the history
  • Loading branch information
wenh06 committed Aug 13, 2023
1 parent 1949d05 commit 04c04e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bib_lookup/bib_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ def _to_bib_item(
field_dict = OrderedDict()
for line in lines[1:-1]:
key, *val = line.strip().split("=") # urls might contain "="
val = "".join(val)
val = "=".join(val)
if key.strip().lower() in BIB_FIELDS:
# field_dict[key.strip()] = val.strip(", ")
field_dict[key.strip()] = val
Expand Down
8 changes: 8 additions & 0 deletions sample-files/large_database.bib
Original file line number Diff line number Diff line change
Expand Up @@ -5900,3 +5900,11 @@ @inproceedings{kiyasseh2021clocs
year = {2021},
organization = {{PMLR}}
}

@inproceedings{dosovitskiy2021_vit,
title = {{An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale}},
author = {Alexey Dosovitskiy and Lucas Beyer and Alexander Kolesnikov and Dirk Weissenborn and Xiaohua Zhai and Thomas Unterthiner and Mostafa Dehghani and Matthias Minderer and Georg Heigold and Sylvain Gelly and Jakob Uszkoreit and Neil Houlsby},
booktitle = {International Conference on Learning Representations},
year = {2021},
url = {https://openreview.net/forum?id=YicbFdNTTy}
}
7 changes: 6 additions & 1 deletion test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ def test_io_from_file():
_OUTPUT_FILE_1.unlink()

bib_items = bl.read_bib_file(_LARGE_DATABASE_FILE, cache=True)
assert len(bib_items) == len(bl) == 608
assert len(bib_items) == len(bl) == 609
special_item = [
item for item in bib_items if item.identifier == "dosovitskiy2021_vit"
][0]
# make sure that "=" is not escaped in the url field after reading from file
assert special_item.url == "https://openreview.net/forum?id=YicbFdNTTy"
bl.clear_cache()
assert len(bl) == 0

Expand Down

0 comments on commit 04c04e4

Please sign in to comment.