Skip to content

Commit

Permalink
Propagate volume "editor" field to contained papers (acl-org#2798)
Browse files Browse the repository at this point in the history
* Propagate volume "editor" field to contained papers

* Add editor to metadata list on paper pages

* Remove AnthologyIndex.verify()

Removing `AnthologyIndex.verify()` because it doesn't actually do what it
advertises. The comment suggests that it throws an error when a name is used
both without and with more than one explicit ID; what it actually checks is if
the paper is used more than once with an explicit ID, even if that ID is always
the same. The ambiguity check should already be performed in
`AnthologyIndex.register()`, so I don't see a reason to keep this function
around at all, because all it does right now is raise false positives.

* Add CSL file to this repo and adjust it to current ACL bst style
  • Loading branch information
mbollmann authored Oct 30, 2023
1 parent 970bf03 commit 23ccc39
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 54 deletions.
309 changes: 309 additions & 0 deletions bin/acl.csl
Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never" default-locale="en-US">
<info>
<title>Association for Computational Linguistics - Conference Proceedings</title>
<title-short>ACL</title-short>
<id>http://www.zotero.org/styles/association-for-computational-linguistics</id>
<link href="http://www.zotero.org/styles/association-for-computational-linguistics" rel="self"/>
<link href="http://www.aclweb.org/" rel="documentation"/>
<!-- No stable link for style documentation; cf. acl.bst, a bibtex style file distributed in each conference. -->
<!-- According to acl.bst, the ACL Conference Proceedings Style was based on the `aaai-named` format by Oren Patashnik in 1985, and later modified for the Proceedings of the ACL by Peter F. Patel-Schneider in 1988, Stuart Shieber in 1991, and Fernando Pereira in 1992. -->
<author>
<name>Hajime Senuma</name>
<email>[email protected]</email>
<uri>https://github.com/hajimes</uri>
</author>
<category citation-format="author-date"/>
<category field="engineering"/>
<category field="linguistics"/>
<summary>CSL for papers in ACL-related conference proceedings, e.g., ACL-HLT, EACL, NAACL-HTL, and EMNLP. (But NOT for the journal "Computational Linguistics")</summary>
<published>2013-11-20T21:00:00Z</published>
<updated>2013-11-20T21:00:00Z</updated>
<rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
</info>
<macro name="author">
<names variable="author">
<name form="long" and="text" delimiter=", "/>
<substitute>
<text value=""/>
</substitute>
</names>
</macro>
<macro name="author-short">
<names variable="author">
<name form="short" and="text" delimiter=", "/>
<substitute>
<names variable="editor">
<name form="short" and="text" delimiter=", "/>
</names>
<text value="mis"/>
</substitute>
</names>
</macro>
<macro name="editor">
<names variable="editor">
<name form="long" and="text" delimiter=", "/>
<label prefix=", " form="long"/>
</names>
</macro>
<macro name="author-or-editor">
<names variable="author">
<name form="long" and="text" delimiter=", "/>
<substitute>
<text macro="editor"/>
<text value=""/>
</substitute>
</names>
</macro>
<macro name="year-date">
<choose>
<if variable="issued">
<date variable="issued">
<date-part name="year"/>
</date>
</if>
<else>
<text value=" "/>
</else>
</choose>
</macro>
<macro name="month">
<date variable="issued">
<date-part name="month"/>
</date>
</macro>
<macro name="edition">
<number variable="edition" form="ordinal"/>
<text term="edition" prefix=" "/>
</macro>
<macro name="volume-or-number">
<choose>
<if variable="volume">
<group delimiter=" ">
<label variable="volume"/>
<number variable="volume"/>
</group>
</if>
<else-if variable="number">
<group delimiter=" ">
<text value="number"/>
<number variable="number"/>
</group>
</else-if>
<else-if variable="issue">
<group delimiter=" ">
<text value="number"/>
<number variable="issue"/>
</group>
</else-if>
</choose>
</macro>
<macro name="event-or-publisher-place">
<choose>
<if variable="event-place">
<text variable="event-place"/>
</if>
<else>
<text variable="publisher-place"/>
</else>
</choose>
</macro>
<macro name="thesis-type">
<choose>
<if variable="genre">
<text variable="genre"/>
</if>
<else>
<text value="Ph.D. thesis"/>
</else>
</choose>
</macro>
<macro name="volume-and-collection-title">
<choose>
<if variable="volume collection-title" match="all">
<group delimiter=" ">
<text term="volume"/>
<number variable="volume"/>
<text value="of"/>
<text variable="collection-title" font-style="italic"/>
</group>
</if>
<else-if variable="volume">
<group delimiter=" ">
<text term="volume"/>
<number variable="volume"/>
</group>
</else-if>
<!-- TODO: else-if for issue or number-->
<else>
<text variable="collection-title"/>
</else>
</choose>
</macro>
<macro name="technical-report">
<choose>
<if variable="number issue" match="any">
<group delimiter=" ">
<!-- uppercased "report" -->
<text value="Technical Report"/>
<choose>
<if variable="number">
<text variable="number"/>
</if>
<else>
<text variable="issue"/>
</else>
</choose>
</group>
</if>
<else>
<!-- lowercased "report" -->
<text value="Technical report"/>
</else>
</choose>
</macro>
<citation et-al-min="3" et-al-use-first="1" disambiguate-add-year-suffix="true">
<!-- no sorting for citation -->
<layout prefix="(" suffix=")" delimiter="; ">
<text macro="author-short"/>
<text macro="year-date" prefix=", "/>
</layout>
</citation>
<bibliography et-al-min="20" et-al-use-first="19">
<sort>
<key macro="author-or-editor"/>
<key macro="year-date"/>
<key variable="title"/>
</sort>
<layout>
<!-- author -->
<choose>
<if type="book">
<text macro="author-or-editor" suffix="."/>
</if>
<else>
<text macro="author" suffix="."/>
</else>
</choose>
<!-- year -->
<date variable="issued" prefix=" " suffix=".">
<date-part name="year"/>
</date>
<!-- title and other information -->
<choose>
<!-- corresponds to "article" in bibtex -->
<if type="article-journal">
<text variable="title" prefix=" " suffix="."/>
<group prefix=" " suffix=".">
<text variable="container-title" font-style="italic"/>
<text variable="volume" prefix=", "/>
<text variable="issue" prefix="(" suffix=")"/>
<text variable="page" prefix=":"/>
<text macro="month" prefix=", "/>
</group>
</if>
<!-- corresponds to "proceedings", "manual", "book", and "periodical" in bibtex -->
<else-if type="book">
<text variable="title" prefix=" " suffix="." font-style="italic"/>
<group delimiter=", " suffix=".">
<text macro="volume-and-collection-title"/>
</group>
<group delimiter=", " prefix=" " suffix=".">
<text variable="publisher"/>
<text variable="publisher-place"/>
<text macro="edition"/>
<text macro="month"/>
</group>
</else-if>
<!-- corresponds to "inbook" and "incollection" in bibtex -->
<else-if type="chapter">
<text variable="title" prefix=" " suffix="."/>
<text term="in" text-case="capitalize-first" prefix=" " suffix=" "/>
<group delimiter=", " suffix=".">
<text macro="editor"/>
<text variable="container-title" font-style="italic"/>
<text macro="volume-and-collection-title"/>
<group delimiter=" ">
<text term="chapter"/>
<number variable="chapter-number"/>
</group>
<group delimiter=" ">
<label variable="page"/>
<text variable="page"/>
</group>
</group>
<group delimiter=", " prefix=" " suffix=".">
<text variable="publisher"/>
<text variable="publisher-place"/>
<text macro="edition"/>
<text macro="month"/>
</group>
</else-if>
<!-- corresponds to "booklet" in bibtex -->
<else-if type="pamphlet">
<text variable="title" prefix=" " suffix="."/>
<group delimiter=", " prefix=" " suffix=".">
<text variable="publisher-place"/>
<text macro="month"/>
</group>
</else-if>
<!-- corresponds to "inproceedings" and "conference" in bibtex -->
<else-if type="paper-conference">
<text variable="title" prefix=" " suffix=". "/>
<text term="in" text-case="capitalize-first" suffix=" "/>
<group suffix="." delimiter=", ">
<!-- <text macro="editor"/> not rendered by current ACL style file -->
<text variable="container-title" font-style="italic"/>
<text macro="volume-or-number"/>
<group delimiter=" ">
<label variable="page"/>
<text variable="page"/>
</group>
<choose>
<if variable="event-place publisher-place" match="any">
<text macro="event-or-publisher-place"/>
<text macro="month"/>
</if>
</choose>
</group>
<group prefix=" " suffix="." delimiter=", ">
<text variable="publisher"/>
<choose>
<if variable="event-place publisher-place" match="none">
<text macro="month"/>
</if>
</choose>
</group>
</else-if>
<!-- corresponds to "techreport" in bibtex -->
<else-if type="report">
<text variable="title" prefix=" " suffix="."/>
<group delimiter=", " prefix=" " suffix=".">
<text macro="technical-report"/>
<text variable="publisher"/>
<text variable="publisher-place"/>
<text macro="month"/>
</group>
</else-if>
<!-- corresponds to "phdthesis" and "masterthesis" in bibtex -->
<else-if type="thesis">
<text variable="title" prefix=" " suffix="." font-style="italic"/>
<group delimiter=", " prefix=" " suffix=".">
<!-- If you want to output text other than "Ph.D thesis", specify the "genre" field to an appropriate value like "Master's thesis".-->
<text macro="thesis-type"/>
<text variable="publisher"/>
<text variable="publisher-place"/>
<text macro="month"/>
</group>
</else-if>
<!-- misc. -->
<else>
<text variable="title" prefix=" " suffix="."/>
<text macro="month" prefix=" " suffix="."/>
</else>
</choose>
<!-- note -->
<text variable="note" prefix=" " suffix="."/>
</layout>
</bibliography>
</style>
1 change: 0 additions & 1 deletion bin/anthology/anthology.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def import_directory(self, importdir):
self.sigs = SIGIndex(importdir)
for xmlfile in (importdir / "xml").glob("*.xml"):
self.import_file(xmlfile)
self.pindex.verify()

def import_file(self, filename):
tree = etree.parse(filename)
Expand Down
11 changes: 8 additions & 3 deletions bin/anthology/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from citeproc.source.json import CiteProcJSON
import citeproc_styles
import codecs
import os
import re

from . import latexcodec
Expand Down Expand Up @@ -60,9 +61,13 @@ class CiteprocFormatter:
def load_style(cls, style):
"""Loads and returns a CSL style."""
if style not in cls.styles:
cls.styles[style] = citeproc.CitationStylesStyle(
citeproc_styles.get_style_filepath(style)
)
if os.path.exists(style):
# Assume that 'style' is a filename
filepath = style
else:
# Assume that 'style' is the name of a style in citeproc_styles
filepath = citeproc_styles.get_style_filepath(style)
cls.styles[style] = citeproc.CitationStylesStyle(filepath)
return cls.styles[style]

@classmethod
Expand Down
24 changes: 0 additions & 24 deletions bin/anthology/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,30 +354,6 @@ def similar(self):
)
return self._similar

def verify(self):
## no longer issuing a warning for unused variants
## it is generally a good idea to keep them around in case they pop up again
## if you want to prune them, try clean_name_variants.py
# for name, ids in self.name_to_ids.items():
# for id_ in ids:
# cname = self.id_to_canonical[id_]
# if name != cname and name not in self._id_to_used[id_]:
# log.warning(
# "Variant name '{}' of '{}' is not used".format(
# repr(name), repr(cname)
# )
# )
if self._fast_load:
return # does nothing
for name, d in self.name_to_papers.items():
# name appears with more than one explicit id and also
# appears without id at least once
if len(d[False]) > 0 and len(d[True]) > 1:
log.error(f"Name '{name}' is ambiguous and is used without explicit id")
log.error(
" Please add an id to paper(s): {}".format(" ".join(d[False]))
)

def personids(self):
return self.id_to_canonical.keys()

Expand Down
Loading

0 comments on commit 23ccc39

Please sign in to comment.