Citation Writer

This notebook shows how to generate a formatted citation in one of the 1000s of styles supported by the Citation Style Language. The citation is returned as a string in HTML format, supporting a limited subset of HTML tags (such as <i> and <sup>).

Fetch metadata

As with all commonmeta-py notebooks, we start by fetching metadata, in this example a journal article via its Crossref DOI, an then convert them to the internal 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

Generate a formatted citation

Using the citation writer, commonmeta-py can generate a formatted citation for the resource, using one of the citation styles defined in the Citation Style Language. The default style is apa, which is the American Psychological Association 7th Edition style. The style is not only very popular and well-documented, but is one of only a few styles that has specific support for special content types, such as dataset and software. And unlike many other styles, it includes the DOI expressed as URL in the citation.

Journal article

citation = metadata.citation()
Sankar, M., Nieminen, K., Ragni, L., Xenarios, I., &amp; Hardtke, C. S. (2014). Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth. <i>Elife</i>, <i>3</i>.

Conference proceedings

metadata = Metadata('10.1109/iccv.2007.4408927')
citation = metadata.citation()
Sinop, A. K., &amp; Grady, L. (2007). A Seeded Image Segmentation Framework Unifying Graph Cuts And Random Walker Which Yields A New Algorithm. In <i>2007 IEEE 11th International Conference on Computer Vision</i>. Institute of Electrical and Electronics Engineers (IEEE).

Book chapter

metadata = Metadata('10.1007/978-3-642-33191-6_49')
citation = metadata.citation()
Chen, L., Panin, G., &amp; Knoll, A. (2012). Human Body Orientation Estimation in Multiview Scenarios. In <i>Advances in Visual Computing</i> (pp. 499–508). Springer Science and Business Media LLC.


metadata = Metadata('10.5061/dryad.8515')
citation = metadata.citation()
Ollomo, B., Durand, P., Prugnolle, F., Douzery, E. J. P., Arnathau, C., Nkoghe, D., Leroy, E., &amp; Renaud, F. (2011). <i>Data from: A new malaria agent in African hominids.</i> (Version 1) [Data set]. Dryad.


# TODO properly handle software type
metadata = Metadata('10.5281/zenodo.48440')
citation = metadata.citation()
Garza, K. (2016). <i>Analysis Tools for Crossover Experiment of UI using Choice Architecture</i> (v1.0) [Computer software]. Zenodo.

Citation Locales

The other option in the citation writer is the locale, which is the language in which the citation is written (words like dates, not the metadata that comes from Crossref). The default locale is en-US, we use es-ES here. The locales are defined in the Citation Style Language repository. I am using an example from Crossref where the metadata are also in Spanish.

metadata = Metadata("10.18558/fil026")
metadata.locale = 'es-ES' = 'modern-language-association'
citation = metadata.citation()
Laborde, F. <i>Biografía De Juan Bautista Alberdi</i>. Fundacion Ignacio Larramendi, 2010, doi:10.18558/fil026.