diff --git a/.gitignore b/.gitignore index cf0d47c85c..b0b02b6516 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ Icon #virtual environment /venv/ + +.coverage diff --git a/bin/anthology/people.py b/bin/anthology/people.py index c146430efe..5420864c97 100644 --- a/bin/anthology/people.py +++ b/bin/anthology/people.py @@ -39,21 +39,29 @@ def score_variant(name): class PersonName: - first, last = "", "" + """ + Represents an instance of a person name. + """ - def __init__(self, first, last, script="roman", variant: "PersonName" = None): + def __init__( + self, first, last, affiliation=None, script="roman", variant: "PersonName" = None + ): + """ + Initialize an instance of a person's name. + """ self.first = first if first is not None else "" self.last = last + self.affiliation = affiliation self.script = script self.variant = variant def from_element(person_element): """ Reads from the XML, which includes an optional first name, a last name, - and an optional variant (itself containing an optional first name, and a - last name). + affiliation, and an optional variant (itself containing an optional first name, + and a last name). """ - first, last = "", "" + first, last, affiliation = "", "", "" # The name variant script, defaults to roman script = person_element.attrib.get("script", "roman") variant = None @@ -65,10 +73,14 @@ def from_element(person_element): first = element.text or "" elif tag == "last": last = element.text or "" + elif tag == "affiliation": + affiliation = element.text or "" elif tag == "variant": variant = PersonName.from_element(element) - return PersonName(first, last, script=script, variant=variant) + return PersonName( + first, last, affiliation=affiliation, script=script, variant=variant + ) def from_repr(repr_): parts = repr_.split(" || ") @@ -133,7 +145,14 @@ def as_citeproc_json(self): return {"family": self.last, "given": self.first} def as_dict(self): - return {"first": self.first, "last": self.last, "full": self.full} + d = { + "first": self.first, + "last": self.last, + "full": self.full, + } + if self.affiliation: + d["affiliation"] = self.affiliation + return d def without_variant(self): if self.variant is None: @@ -154,6 +173,8 @@ def __lt__(self, other): return self.full < other.full def __str__(self): + if self.affiliation: + return f"{self.full} ({self.affiliation})" return self.full def __repr__(self): diff --git a/bin/create_hugo_yaml.py b/bin/create_hugo_yaml.py index c58bf95aa0..932f87e3bc 100755 --- a/bin/create_hugo_yaml.py +++ b/bin/create_hugo_yaml.py @@ -58,6 +58,7 @@ def export_anthology(anthology, outdir, clean=False, dryrun=False): # "mla": "modern-language-association-7th-edition", } + # Load paper information for id_, paper in anthology.papers.items(): log.debug("export_anthology: processing paper '{}'".format(id_)) data = paper.as_dict() @@ -192,6 +193,7 @@ def volume_sorter(volume): # the alphabetically-earliest volume return min(volumes[volume]["venues"]) + # sort volumes event_data["volumes"] = sorted(event_data["volumes"], key=volume_sorter) events[event_name] = event_data diff --git a/data/xml/W18.xml b/data/xml/W18.xml index 857cb9f209..05c94dce7b 100644 --- a/data/xml/W18.xml +++ b/data/xml/W18.xml @@ -13121,7 +13121,7 @@ A Call for Clarity in Reporting <fixed-case>BLEU</fixed-case> Scores - MattPost + MattPostAmazon 186–191 W18-6319 W18-6319.Poster.pdf diff --git a/hugo/layouts/papers/single.html b/hugo/layouts/papers/single.html index 6ee2bd420d..1e208bb647 100644 --- a/hugo/layouts/papers/single.html +++ b/hugo/layouts/papers/single.html @@ -4,7 +4,14 @@ {{ range $paper.author }} {{ $first_letter := slicestr .id 0 1 }} - + {{ $author := index .Site.Data.people $first_letter .id }} + + {{ with $author.affiliation }} + + {{ end }} + {{ with $author.orcid }} + + {{ end }} {{ end }} {{ with $paper.parent_volume_id }} {{ $volume := index $.Site.Data.volumes . }}