Skip to content

Instantly share code, notes, and snippets.

@jagot
Last active October 22, 2017 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagot/e47dc6c2785beb81ee38aadae0711a6e to your computer and use it in GitHub Desktop.
Save jagot/e47dc6c2785beb81ee38aadae0711a6e to your computer and use it in GitHub Desktop.
Script to generate journal abbrevations for use with Biber
# http://library.stanford.edu/guides/find-journal-abbreviations
# http://images.webofknowledge.com/images/help/WOS/N_abrvjt.html
# https://limitedknowledge.wordpress.com/2014/10/17/abbreviations-of-scientific-journals-needed-for-your-bibliography/
Advances in Atomic and Molecular Physics|Adv. Atom. Mol. Phys.
Advances in Chemical Physics|Adv. Chem. Phys.
Chemical Physics Letters|Chem. Phys. Lett.
Chemical Physics|Chem. Phys.
Computer Physics Communications|Comput. Phys. Commun.
Faraday Discussions|Faraday Discuss.
High Power Laser Science and Engineering|High Power Laser Sci. Eng.
Journal of Experimental and Theoretical Physics|J. Exp. Theor. Phys.
Journal of Physics B: Atomic, Molecular and Optical Physics|J. Phys. B: AMO Phys.
Journal of the Optical Society of America B|J. Opt. Soc. Am. B
Nano Letters|Nano Lett.
Nature Communications|Nat. Comm.
Nature Photonics|Nat. Phot.
Nature Physics|Nat. Phys.
New Journal of Physics|New J. Phys.
Physical Review A|Phys. Rev. A
Physical Review Letters|Phys. Rev. Lett.
Reports on Progress in Physics|Rep. Prog. Phys.
Review of Scientific Instruments|Rev. Sci. Instrum.
Reviews of Modern Physics|Rev. Mod. Phys.
Scientific Reports|Sci. Rep.
The Journal of Chemical Physics|J. Chem. Phys.
The Journal of Physical Chemistry A|J. Phys. Chem. A
using Graphs
abbrvs = filter(readlines("abbrvs")) do line
!ismatch(r"^([ ]*)#", line)
end
entries = map(abbrvs) do abbrv
a,b=split(abbrv,"|")
string(a),string(b)
end
g = simple_graph(length(entries))
for i in eachindex(entries)
for j in eachindex(entries)
i == j && continue
contains(entries[i][1], entries[j][1]) && add_edge!(g, i, j)
end
end
p = topological_sort_by_dfs(g)
permute!(entries, p)
entries = map(entries) do abbrv
a,b = abbrv
title = replace(a, " ", "\\s")
fe = map(["journal","journaltitle","booktitle"]) do field
"""
<map_step map_field_source="$(field)"
map_match = "$(title)"
map_replace = "$(b)"/>"""
end
join(fe, "\n")
end
entries = join(entries, "\n")
xml = """<?xml version="1.0" encoding="UTF-8"?>
<config>
<sorting>
<presort>mm</presort>
<sort order="1">
<sortitem order="1">author</sortitem>
</sort>
<sort order="2">
<sortitem order="1">year</sortitem>
</sort>
</sorting>
<sourcemap>
<maps datatype="bibtex">
<map map_overwrite="1">
$(entries)
</map>
</maps>
</sourcemap>
</config>
"""
open("biber.conf", "w") do file
write(file, xml)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment