BibTex Writer

This notebook shows how to generate BibTex metadata from a scholarly resource in commonmeta format generated by commonmeta-py.

Fetch metadata

As with all commonmeta-by notebooks, we start by fetching metadata, in this example a journal article via its Crossref DOI, and then convert it to the commonmeta format.

from commonmeta import Metadata

# Fetch metadata from a DOI
string = "10.7554/elife.01567"
metadata = Metadata(string)

# Check that metadata was fetched successfully
print(metadata.state)
findable

Generate BibTex

We can now generate BibTex metadata from the article metadata. We use the commonmeta pid (here a doi) to generate a BibTex key. Because BibTex has been around for more than 30 years, there are many flavours of it, including the list of supported types and the fields that are included. We try to align with the fields supported by Zotero, which is a popular reference manager. We for example include the abstract, copyright and language fields.

bibtex = metadata.write(to="bibtex")
print(bibtex)
@article{10.7554/elife.01567,
    abstract = {Among various advantages, their small size makes model organisms preferred subjects of investigation. Yet, even in model systems detailed analysis of numerous developmental processes at cellular level is severely hampered by their scale. For instance, secondary growth of Arabidopsis hypocotyls creates a radial pattern of highly specialized tissues that comprises several thousand cells starting from a few dozen. This dynamic process is difficult to follow because of its scale and because it can only be investigated invasively, precluding comprehensive understanding of the cell proliferation, differentiation, and patterning events involved. To overcome such limitation, we established an automated quantitative histology approach. We acquired hypocotyl cross-sections from tiled high-resolution images and extracted their information content using custom high-throughput image processing and segmentation. Coupled with automated cell type recognition through machine learning, we could establish a cellular resolution atlas that reveals vascular morphodynamics during secondary growth, for example equidistant phloem pole formation.},
    author = {Sankar, Martial and Nieminen, Kaisa and Ragni, Laura and Xenarios, Ioannis and Hardtke, Christian S},
    copyright = {https://creativecommons.org/licenses/by/3.0/legalcode},
    doi = {10.7554/elife.01567},
    issn = {2050-084X},
    journal = {eLife},
    language = {en},
    month = feb,
    title = {Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth},
    url = {https://elifesciences.org/articles/01567},
    urldate = {2014-02-11},
    year = {2014}
}

Supported BibTex Types

commonmeta-py supports the following BibTex types: article, book, booklet, conference, inbook, incollection, inproceedings, manual, mastersthesis, misc, phdthesis, proceedings, techreport, unpublished. Types that are not supported are mapped to misc, and that includes software and dataset, which were not part of the original BibTex specification. Below are examples of BibTex metadata for types other than article:

Book chapter

metadata = Metadata("10.1007/978-3-662-46370-3_13")
bibtex = metadata.write(to="bibtex")
print(bibtex)
@inbook{10.1007/978-3-662-46370-3_13,
    author = {Diercks, Ronald L. and Ludvigsen, Tom Clement},
    booktitle = {Shoulder Stiffness},
    copyright = {https://www.springernature.com/gp/researchers/text-and-data-mining},
    doi = {10.1007/978-3-662-46370-3_13},
    isbn = {9783662463703},
    language = {en},
    month = oct,
    pages = {155--158},
    publisher = {Springer Berlin Heidelberg},
    title = {Clinical Symptoms and Physical Examinations},
    url = {https://link.springer.com/10.1007/978-3-662-46370-3_13},
    urldate = {2015},
    year = {2015}
}

Conference proceedings

metadata = Metadata("10.1109/iccv.2007.4408927")
bibtex = metadata.write(to="bibtex")
print(bibtex)
{'submitted': None, 'accepted': None, 'published': '2007', 'updated': '2017-06-18T02:39:45Z'}
@inproceedings{https://doi.org/10.1109/iccv.2007.4408927,
    author = {Sinop, Ali Kemal and Grady, Leo},
    booktitle = {2007 IEEE 11th International Conference on Computer Vision},
    doi = {10.1109/iccv.2007.4408927},
    month = mar,
    publisher = {Institute of Electrical and Electronics Engineers (IEEE)},
    title = {A Seeded Image Segmentation Framework Unifying Graph Cuts And Random Walker Which Yields A New Algorithm},
    url = {http://ieeexplore.ieee.org/document/4408927},
    urldate = {2007},
    year = {2007}
}

PhD thesis

metadata = Metadata("10.14264/uql.2020.791")
bibtex = metadata.write(to="bibtex")
print(bibtex)
@phdthesis{10.14264/uql.2020.791,
    author = {Collingwood, Patricia Maree},
    doi = {10.14264/uql.2020.791},
    institution = {University of Queensland Library},
    month = jun,
    title = {School truancy and financial independence during emerging adulthood: a longitudinal analysis of receipt of and reliance on cash transfers},
    url = {http://espace.library.uq.edu.au/view/UQ:23a1e74},
    urldate = {2020-06-08},
    year = {2020}
}

Differences between Crossref JSON and XML

The metadata provided by the Crossref JSON REST API are slightly different than the UNIXREF XML submitted to Crossref upon DOI registration. Compare the following two examples (the default is ‘crossref’ for Crossref DOIs):

string = "10.1145/3448016.3452841"
metadata = Metadata(string, via="crossref")
bibtex = metadata.write(to="bibtex")
print(bibtex)
@inproceedings{10.1145/3448016.3452841,
    author = {Pandey, Prashant and Conway, Alex and Durie, Joe and Bender, Michael A. and Farach-Colton, Martin and Johnson, Rob},
    booktitle = {Proceedings of the 2021 International Conference on Management of Data},
    copyright = {https://creativecommons.org/licenses/by/4.0/legalcode},
    doi = {10.1145/3448016.3452841},
    month = jun,
    pages = {1386--1399},
    publisher = {ACM},
    title = {Vector Quotient Filters: Overcoming the Time/Space Trade-Off in Filter Design},
    url = {https://dl.acm.org/doi/10.1145/3448016.3452841},
    urldate = {2021-06-09},
    year = {2021}
}
string = "10.1145/3448016.3452841"
metadata = Metadata(string, via="crossref_xml")
bibtex = metadata.write(to="bibtex")
print(bibtex)
@inproceedings{10.1145/3448016.3452841,
    author = {Pandey, Prashant and Conway, Alex and Durie, Joe and Bender, Michael A. and Farach-Colton, Martin and Johnson, Rob},
    booktitle = {Proceedings of the 2021 International Conference on Management of Data},
    copyright = {https://creativecommons.org/licenses/by/4.0/legalcode},
    doi = {10.1145/3448016.3452841},
    isbn = {9781450383431},
    location = {Virtual Event China},
    month = jun,
    pages = {1386--1399},
    publisher = {Association for Computing Machinery (ACM)},
    series = {SIGMOD/PODS '21},
    title = {Vector Quotient Filters: Overcoming the Time/Space Trade-Off in Filter Design},
    url = {https://dl.acm.org/doi/10.1145/3448016.3452841},
    urldate = {2021-06-09},
    year = {2021}
}

BibTex Author names

BibTex writes author names as a single string, joined by and. Personal names are written as family, given and organizational names as name. An example for the latter:

# Organizations as authors
metadata = Metadata("10.26301/qdpd-2250")
bibtex = metadata.write(to="bibtex")
print(bibtex)
@misc{10.26301/qdpd-2250,
    abstract = {USS Pampanito was towed to Bay Ship Yacht shipyard and raised out of the water in a dry dock for repairs. On Friday, November 11, 2016 the submarine was scanned. Our goal was to create a baseline scan for future comparison, to inform future repairs, to compare to her builders drawings, and to facilitate interpretation and research. USS Pampanito made six patrols in the Pacific during World War II during which she sank six Imperial Japanese ships and damaged four others. Operated by the Maritime Park Association, Pampanito hosts over 100,000 visitors a year and is one of the most popular historic vessels in the country. In addition to day time visitors, over 1,500 kids a year participate in Pampanito's educational day and overnight programs. Pampanito is a National Historic Landmark. External Project Link: \N Additional Info Link: https://maritime.org/sub/},
    author = {Pampanito, USS and Autodesk and Topcon and Robotics, 3D and CyArk and San Francisco Maritime National Park Association},
    copyright = {https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode},
    doi = {10.26301/qdpd-2250},
    month = oct,
    publisher = {OpenHeritage3D},
    title = {USS Pampanito Submarine},
    url = {https://openheritage3d.org/project/qdpd-2250},
    urldate = {2020},
    year = {2020}
}