Skip to content

people.name

ConvertableIntoName module-attribute

ConvertableIntoName = (
    Name | str | tuple[Optional[str], str] | dict[str, str]
)

A type that can be converted into a Name instance.

LAST_NAME_CAPITALIZATION_RULES module-attribute

LAST_NAME_CAPITALIZATION_RULES = (
    ("^Mc([a-z])", lambda p: "Mc" + upper()),
)

Regex rules for heuristically normalizing last names; used for acl_anthology.people.name.Name.case_normalize.

LAST_NAME_LOWERCASE_PREFIXES module-attribute

LAST_NAME_LOWERCASE_PREFIXES = {
    "al",
    "bin",
    "bint",
    "da",
    "de",
    "del",
    "de la",
    "dela",
    "della",
    "di",
    "dos",
    "du",
    "el",
    "la",
    "le",
    "van",
    "van den",
    "van der",
    "von",
    "von der",
}

Strings that tend to be lowercased when prefixing a last name; used for NameSpecification.case_normalize().

SLUGIFY_REPLACEMENTS module-attribute

SLUGIFY_REPLACEMENTS = (['ʼ', '-'], ['’', '-'])

Custom replacement rules for name slugs.

Name

A person's name.

Note

Name objects are frozen, meaning they are immutable. This allows them to be used as dictionary keys, but means that in order to change a name somewhere, you need to replace it with a new Name instance.

Attributes:

Name Type Description
first Optional[str]

First name part. Can be given as None for people who only have a single name, but cannot be omitted.

last str

Last name part.

script Optional[str]

The script in which the name is written; only used for non-Latin script name variants.

Examples:

>>> Name("Yang", "Liu")
>>> Name(last="Liu", first="Yang")
>>> Name(None, "Mausam")

as_bibtex cached

as_bibtex()

Returns:

Type Description
str

The person's full name as formatted in a BibTeX entry.

as_first_last

as_first_last()

Returns:

Type Description
str

The person's full name in the form '{first} {last}'.

as_full

as_full()

Builds the full name, determining the appropriate format based on the script.

Returns:

Type Description
str

For Han names, this will be '{last}{first}'; for other scripts (or if no script is given), this will be '{first} {last}'.

as_last_first

as_last_first()

Returns:

Type Description
str

The person's full name in the form '{last}, {first}'.

case_normalize

case_normalize(force=False)

Try to heuristically normalize the casing of the name.

By default, this only changes the name if it is currently all-lowercased or all-uppercased.

Parameters:

Name Type Description Default
force bool

Always case-normalize, without checking the current casing.

False

Raises:

Type Description
ValueError

If the name's script attribute is set, indicating a non-Latin script name.

from_ classmethod

from_(name)

Instantiate a Name dynamically from any type that can be converted into a Name.

Parameters:

Name Type Description Default
name ConvertableIntoName

A name as a string, dict, tuple, or Name instance.

required

Returns:

Type Description
Name

A corresponding Name object.

Raises:

Type Description
ValueError
TypeError

from_dict classmethod

from_dict(name)

Parameters:

Name Type Description Default
name dict[str, str]

A dictionary with at least a "last" key, and optionally "first" and "script" keys.

required

Returns:

Type Description
Name

A corresponding Name object.

from_string classmethod

from_string(name)

Instantiate a Name from a single string.

Parameters:

Name Type Description Default
name str

A name string given as either "{first} {last}" or "{last}, {first}".

required

Returns:

Type Description
Name

A corresponding Name object.

Raises:

Type Description
ValueError

If name cannot be unambiguously parsed into first/last components; in this case, you should instantiate Name directly instead.

from_xml classmethod

from_xml(variant)

Parameters:

Name Type Description Default
variant _Element

An XML element of a <variant> block.

required

Returns:

Type Description
Name

A corresponding Name object.

Note

This will work for <author> and <editor> tags as well, but those are more efficiently parsed within NameSpecification.from_xml().

score

score()

Returns:

Type Description
float

A score for this name that is intended for comparing different names that generate the same ID. Names that are more likely to be the correct canonical variant should return higher scores via this function.

slugify cached

slugify()

Returns:

Type Description
str

A slugified string of the full name.

to_xml

to_xml(tag='variant')

Parameters:

Name Type Description Default
tag str

Name of outer tag in which the name should be wrapped.

'variant'

Returns:

Type Description
_Element

A serialization of this name in Anthology XML format.

NameSpecification

A name specification on a paper etc., containing additional data fields for information or disambiguation besides just the name.

Attributes:

Name Type Description
parent Optional[Paper | Volume | Talk]

The Anthology item that this name specification belongs to.

orcid Optional[str]

An ORCID that was supplied together with this name.

affiliation Optional[str]

Professional affiliation.

variants tuple[Name, ...]

Variant spellings of this name in different scripts.

Note

The variants attribute is only intended for name variants stored via the <variant> tag in the XML, i.e., for a name that has a variant in a different script. It is not used when an author has published under different names (for this functionality, see Person).

citeproc_dict cached property

citeproc_dict

A citation object corresponding to this name for use with CiteProcJSON.

first property

first

The first name component.

id property writable

id

Unique ID for the person that this NameSpecification refers to.

last property

last

The last name component.

name property writable

name

The person's name.

root property

root

The Anthology instance to which this object belongs.

case_normalize

case_normalize(force=False)

Try to heuristically normalize the casing of the name.

See acl_anthology.people.name.Name.case_normalize.

from_xml classmethod

from_xml(person)

Parameters:

Name Type Description Default
person _Element

An XML element of an <author> or <editor> block.

required

Returns:

Type Description
NameSpecification

A corresponding NameSpecification object.

resolve

resolve()

Resolve this name specification to a natural person.

Returns:

Type Description
Person

The Person object that this name specification resolves to.

Raises:

Type Description
AnthologyException

If this name specification is not attached to an Anthology item (i.e., parent is not set).

to_xml

to_xml(tag='author')

Parameters:

Name Type Description Default
tag str

Name of outer tag in which the name should be wrapped.

'author'

Returns:

Type Description
_Element

A serialization of this name in Anthology XML format.