0

Is there some tool (disciple-specific or general) which takes as input a .bib file and shortens the entries, as much as possible? e.g.

  • Replacing given names with initials ("Smith, John" -> "Smith, J." and "John Smith" to "J. Smith")
  • Replacing journal and conference names with shorter versions (e.g. "Communications of the ACM" -> "Comm. ACM")
  • Shortens names of cities and states
  • Removes non-critical fields

I don't care whether the changes are in-place or to another file.

Note: I realize the bibliography style can take care of some of this, but - I want to work on .bib files themselves, plus, for the purposes of this question I don't have control of the bibliography style.

einpoklum
  • 12,311
  • 4
    Why in the bib file? Let bib style decide how it looks – wang ki wun Aug 23 '19 at 15:59
  • you knowing https://www.ctan.org/pkg/bibexport and https://github.com/yfpeng/pengyifan-bibtexformat? – wang ki wun Aug 23 '19 at 16:00
  • JabRef does journal abbreviations http://help.jabref.org/en/JournalAbbreviations and while I'm pretty sure it is (or could easily be) powerful enough to do the other things as well I'm not sure if there are predefined functions that let you do the other jobs. Jobs 1 and 4 are usually handled by the bibliography style you use, so I'm not sure how many tools would be out there that offer functionalities like this. – moewe Aug 23 '19 at 16:09
  • @moewe: The thing is, I'm using a style that doesn't shorten names, or much of anything, but I do want shortening anyway. – einpoklum Aug 23 '19 at 16:52
  • @wangkiwun: See edit. – einpoklum Aug 23 '19 at 16:53
  • I figured as much, the last part of my comment was more an attempt to explain why there are few (if any?) tools that allow you to do jobs 1 and 4 with a handy built-in one-click function. Indeed deleting fields from the .bib file somehow goes against what I see as the spirit of BibTeX, but I fully well see that it is the easiest and sometimes maybe even the only solution to produce the output that one might need. – moewe Aug 23 '19 at 20:12
  • 1
    Field deletion according to a data scheme would be possible with Biber in --tool mode (see in particular https://tex.stackexchange.com/q/415028/35864) and with bibtool. https://hsborges.github.io/bibtex-normalizer/ or https://github.com/sirrice/bibcleaner (never used them) might also be of interest – moewe Aug 23 '19 at 20:14

1 Answers1

1

The best way to modify bib files is bibtool. Alternative you could write some simple shell scripts that use sed or awk like bibtools. Most name shortening are substitutions, which you are going to have to specify somewhere regardless of whether the tool exists or you create it. Although some standard ones like journal abbreviations you might be able to find such dictionary online. In the case of person names it can be done with a regular expression, e.g., with GNU sed:

echo "John Smith" | sed -E "s/([A-Z])[a-z]+\s([A-Z][a-z]+)/\1. \2/g"

produces J. Smith.

You can also change the style through packages options e.g., \usepackage[<options>]{biblatex} and that, if possible, would indeed be the best option.

jsb
  • 454