pierre-24 / pyiso4

Implementation of the ISO 4 standard for journal titles abbreviations in Python.
MIT License
4 stars 2 forks source link
iso4 python

pyiso4

An attempt to implement the ISO 4 standard for journal titles abbreviations within a simple application written in Python, as described in Section 7.1 of the ISSN Manual. Inspired by the NPM package abbrevIso.

Install and use

From PyPI:

pip install pysiso4

Usage:

$ iso4abbreviate "Journal of the American Chemical Society"
J. Am. Chem. Soc.

You can abbreviate multiple titles at the same time:

$ iso4abbreviate "Journal of Chemical Physics" "Journal of Physical Chemistry A"
J. Chem. Phys.
J. Phys. Chem. A

By default, the program abbreviate using this list of abbreviation (slightly modified version of LTWA 2021) and this list of stopwords. You can change that using --ltwa and --stopwords to provide your own files instead (with the same syntax as theirs).

As for rule 7.1.11, namely that abbreviations of generic words such as part, etc. are omitted unless they are required, the program removes them by default. To change this behavior, use --keep-part.

Python API

from pyiso4.ltwa import Abbreviate

# create an abbreviator (using the default LTWA)
abbreviator = Abbreviate.create()

# abbreviate something
abbreviation = abbreviator('Journal of the American Chemical Society', remove_part=True)

Known issues

A list of failed tests is found here. It currently fails:

Contributions

Contributions, either by filling issues or via pull requests are welcomed. More information here.