citation-file-format / cffconvert

Command line program to validate and convert CITATION.cff files.
Apache License 2.0
99 stars 28 forks source link

bibtex full name from name parts and capitalisation #156

Closed tvercaut closed 1 year ago

tvercaut commented 3 years ago

Hi,

I am looking into using cff files from some github repos and stumbled onto some issues. The current version is here: https://github.com/Project-MONAI/MONAI/blob/dev/CITATION.cff

It generates the following bibtex:

@misc{MONAI_Consortium_MONAI_Medical_Open_2020,
author = {MONAI Consortium},
doi = {10.5281/zenodo.4323058},
month = {3},
title = {MONAI: Medical Open Network for AI},
url = {https://github.com/Project-MONAI/MONAI},
year = {2020}
}

which means bibtex can transforms the author name to "M. Consortium"

I tried modifying the CFF file to use an entity rather than a person as an author, which seems authorised by the standard

# YAML 1.2
# Metadata for citation of this software according to the CFF format (https://citation-file-format.github.io/)
#
---
title: "MONAI: Medical Open Network for AI"
abstract: "AI Toolkit for Healthcare Imaging"
authors:
  - name: "MONAI Consortium"
date-released: 2020-03-28
version: "0.6.0"
doi: "10.5281/zenodo.4323058"
license: "Apache-2.0"
repository-code: "https://github.com/Project-MONAI/MONAI"
cff-version: "1.1.0"
message: "If you use this software, please cite it using these metadata."

but this led to the author information being dropped in the bibtex output:

@misc{YourReferenceHere,
author = {},
doi = {10.5281/zenodo.4323058},
month = {3},
title = {MONAI: Medical Open Network for AI},
url = {https://github.com/Project-MONAI/MONAI},
year = {2020}
}

Also, is there a way to force the bibtex output to preserve some capitalisation (MONAI in the above)?

Am I missing a better way of handling this?

For the record, I created a simple notebook to test options here: https://colab.research.google.com/drive/1dvLB6LmytoUl7ePmBH5a6Un6gqXegRKD?usp=sharing Note that this doesn't seem to create the bibtex key that github generates so I might be missing something else...

tvercaut commented 3 years ago

Looking at the code, it looks like the different name parts are simply concatenated in the bibtex output: https://github.com/citation-file-format/cff-converter-python/blob/f1bfd6830f8b0a362fa0bee49fcb2e99471dcaad/cffconvert/BibtexObject.py#L45-L51

From the bibtex manual, it would already be nicer to use a format along the lines of:

von Last, Jr, First

or maybe even better

{von Last}, {Jr}, {First}

so that if the Jr or First part is empty we get {von Last}.

So maybe something along the lines of

fullname = ', '.join(['{'+namepart+'}' if (' ' in namepart) else namepart for namepart in nps if namepart is not None])
jspaaks commented 1 year ago

Not exactly what @tvercaut suggested, but I just added name/capitalization protection when the author is an entity, as opposed to a person.

With these changes, a CITATION.cff file like

# YAML 1.2
# Metadata for citation of this software according to the CFF format (https://citation-file-format.github.io/)
#
---
title: "MONAI: Medical Open Network for AI"
abstract: "AI Toolkit for Healthcare Imaging"
authors:
  - name: "MONAI Consortium"
date-released: 2020-03-28
version: "0.6.0"
doi: "10.5281/zenodo.4323058"
license: "Apache-2.0"
repository-code: "https://github.com/Project-MONAI/MONAI"
cff-version: "1.1.0"
message: "If you use this software, please cite it using these metadata."

yields:

$ cffconvert -f bibtex
@misc{YourReferenceHere,
author = {{MONAI Consortium}},
doi = {10.5281/zenodo.4323058},
month = {3},
title = {MONAI: Medical Open Network for AI},
url = {https://github.com/Project-MONAI/MONAI},
year = {2020}
}

thus avoiding the problem of authors showing up as e.g. "M. Consortium"