Repository: acl-org/acl-anthology

Issue:
Name parser
At ingestion time, we are often given data that is not split into BibTeX's "surname, given name" format. We therefore split it ourselves, heuristically, which often fails. Python has a [name parser](https://pypi.org/project/nameparser/) module, but it doesn't work on all Anthology names, either, e.g.,:

- José Alejandro Lopez Gonzalez
- Philippe Boula de Mareüil

It would be cool to implement our own name parser and train it on the Anthology data. (I imagine that applying the trained model would turn up some mistakes in our data).


Discussion:
Is there a place where anthology's author list is available? I quickly grepped `anthology.bib` from a recent conf template for the second authot and even in the anthology there doesn't seem to be a single truth in these cases?

```
$ grep -i 'de mare' anthology.bib 
    author = {de Mare{\"u}il, Philippe Boula  and
      de Mare{\"u}il, P. Boula  and
      Boula de Mare{\"u}il, Philippe  and
      de Mare{\"u}il, Philippe Boula  and
      Boula de Mare{\"u}il, Philippe},
    author = {Boula de Mare{\"u}il, Philippe  and
    author = {Boula de Mare{\"u}il, Philippe  and
      Boula de Mare{\"u}il, Philippe},
```

One simple idea is lexical sorting of words in author string and using `difflib` to get a fuzzy match across word-sorted authors in anthology, which would yield closest matches easily. And then post-editing/verification should potentially be done.
> Is there a place where anthology's author list is available?

Authors are parsed from the XML; you can use the Python API to access them, for example. See here for how it's used to dump a list of authors during site generation:
https://github.com/acl-org/acl-anthology/blob/master/bin/create_hugo_yaml.py#L73

Then there's our list of name variants, partly already automatically generated with fuzzy matching, partly manually curated:
https://github.com/acl-org/acl-anthology/blob/master/data/yaml/name_variants.yaml

I believe the issue Matt is talking about here is that for new authors (that we don't cover yet in our `name_variants.yaml`), it is not always clear how to split them into the surname and given name, and it would be nice to have a heuristic that works better on names *not yet seen in the Anthology.*
Yes, new names are an issue, but there is also currently no way to find the correct splitting of existing names. This is needed at ingestion time, when we bring new volumes into the Anthology by parsing information from an existing BibTeX file. Often, in that file, names will not be split out at all, e.g.,
```bibtex
authors = {Matt Post and José Alejandro Lopez Gonzalez and ...}
```
or will be split incorrectly
```bibtex
authors = {Post, Matt and Gonzalez, José Alejandro Lopez and ...}
```
What I'd like is an API call that will take a name, *unsplit* it, return the correct split if the name exists in the Anthology, or compute the correct split if it is a new name.

Resolving patch:
diff --git a/bin/likely_name_split.py b/bin/likely_name_split.py
--- a/bin/likely_name_split.py
+++ b/bin/likely_name_split.py
@@ -57,8 +57,9 @@ def count_names(self, anthology):
     # returns ("Lopez Gonzalez", "Maria Victoria")
     # uses counts of words in first and last names in current database
     def best_split(self, name):
-        if "," in name:
+        if "," in name and not "Jr." in name:
             # Short-circuit names that are already split
+            # comma in "William Baumgartner, Jr." does not count as a split
             surname, given_names = name.split(",")
             return (surname.strip(), given_names.strip())
 


Test patch: