Repository: acl-org/acl-anthology

Issue:
How to annotate first initials in XML
@mjpost and I have been discussing offline: When an author's name is written using a first initial on the paper itself, but the complete first name is known (at least probably), how should it be written in the XML? Some ideas (others are possible):

```
a) <author><first>Matt</first><last>Post</last></author>
b) <author><first>M[att]</first><last>Post</last></author>
c) <author><first complete="Matt">M.</first><last>Post</last></author>
d) <author><first initials="M.">Matt</first><last>Post</last></author>
e) <author><first>M<completion>att</completion></first><last>Post</last></author>
```

We have a big influx of these, thanks to the hard work of the LREC organizers supplying complete first names, so if the answer is anything other than (a), it would be nice to decide before merging in the new ones.

JATS uses (d) but without the period (https://jats.nlm.nih.gov/archiving/tag-library/1.1d1/n-zu82.html).

Some special cases to consider:

- Initials are not always initials: `Wm.` to `William`, `R.` to `Bob`
- Middle initials, double first names, second last names, etc. can be expanded from initials as well.
- ADDED: Possibly related, possibly a can of worms: There are some (but not many) papers where the author's name is written _only_ in a non-Latin script (e.g., https://www.aclweb.org/anthology/O00-1008), so the editor has filled in a transliteration.


Discussion:
I'm not sure I would want to make a functional difference here between this and any other name variants. The only robust way to clearly identify an author is via some kind of ID. Everything else will only lead to more problems in the future, IMHO. 
The difference between this and other name variants is that the chance of collisions is much higher. So you're right that the name collision problem (#208) is the real issue that needs to be resolved.

I think what makes this tricky is that, abstracting away from any questions like "what is a first/last name?" and focusing on functionality (as decided in #237), the author entries in the XML still serve three purposes:
- Identify an author (by matching an entry in `name_variants.yaml`)
- Generate names for the website and BibTeX
- Record what the authors wrote on the original paper

And these three purposes are not always aligned.
Will it be okay with @mbollmann @mjpost if I go ahead with option (d) for now? This would require only a minor change to the schema, no modifications to code, and it would be easy to convert to another style. It also conforms with an established standard ([JATS](https://jats.nlm.nih.gov/archiving/tag-library/1.1/attribute/initials.html)) and is consistent with [CMoS style](https://www-chicagomanualofstyle-org.proxy.library.nd.edu/book/ed17/part3/ch14/psec073.html), which I believe ACL's style is most similar to. (I also believe that even with a good solution for name collision, this is still the best option.)
This is good for the name collision, but it also means we are overriding author preference as to how their name is displayed, correct? This is in line with JATS policy, but my preference is to gather names under the canonical form that is evidenced by majority vote across the representations an author chose for their papers (i.e., (c)). 

What is your reason for preferring (d) over (c)? 
What I gather from manuals like CMoS is that there's a distinction between whether an author prefers to use initials (e.g., C.S. Lewis), vs. when initials are an abbreviation of the author's preferred spelling (e.g., because the conference requires it, or there wasn't enough space in the titlebox, or the lead author wanted to, or whatever). In the former case, initials shouldn't be expanded, but in the latter case, they can be.

So the rule of thumb would be something like: if an author name uses an initial, and the initial is expanded in a majority of the author's other papers, then expand the initial.



Resolving patch:
diff --git a/bin/check_name_variants.py b/bin/check_name_variants.py
--- a/bin/check_name_variants.py
+++ b/bin/check_name_variants.py
@@ -1,14 +1,19 @@
 import yaml
 import sys
 import lxml.etree as etree
+import logging
 
 person_fields = {'canonical', 'variants', 'comment'}
 name_fields = {'first', 'last', 'papers'}
 
 def text(node):
     """Extract text from an XML node."""
-    if node is None: return ''
-    s = ''.join(node.itertext())
+    if node is None:
+        return ''
+    if 'complete' in node.attrib:
+        s = node.attrib['complete']
+    else:
+        s = ''.join(node.itertext())
     return ' '.join(s.split())
 
 def name(d):
@@ -20,7 +25,7 @@ def name(d):
         try:
             tree = etree.parse(xmlfilename)
         except:
-            print(xmlfilename)
+            logging.error("couldn't parse {}".format(xmlfilename))
             raise
         for paper in tree.getroot().findall('paper'):
             for person in paper.xpath('./author|./editor'):
@@ -40,14 +45,15 @@ def name(d):
     assert isinstance(person['canonical'], dict), person
     assert set(person['canonical']).issubset(name_fields), person
     if names is not None and name(person['canonical']) not in names:
-        print('unused name', person['canonical'])
+        logging.warning('unused name: {}'.format(person['canonical']))
     dupes = {name(person['canonical'])}
     assert 'variants' in person, person
     assert isinstance(person['variants'], list), person
     for variant in person['variants']:
         assert set(variant).issubset(name_fields), person
         if names is not None and name(variant) not in names:
-            print('unused name', variant)
+            logging.warning('unused name: {}'.format(variant))
         assert name(variant) not in dupes, variant
         dupes.add(name(variant))
         
+print(yaml.dump(doc, allow_unicode=True))


Test patch: