Skip to main content

Python library to manage personal names (in onomastic terminology also known as prosoponyms)

Project description

Prosoponym Python Library

Python library to format personal names (in onomastic terminology also known as prosoponyms).

A personal name is the set of names by which an individual person is known, with the understanding that, taken together, they all relate to that one individual. A personal name is generally composed of first names, middle names and last names, which order varies depending on the culture the personal name is related to (western or eastern lexical name orders).

>>> from majormode.perseus.model.locale import Locale
>>> from majormode.prosoponym import LexicalNameOrder
>>> from majormode.prosoponym import format_first_name
>>> from majormode.prosoponym import format_full_name
>>> from majormode.prosoponym import format_last_name

>>> format_first_name("Aline Maria")
'Aline Maria'
>>> format_last_name("caune ly")
'CAUNE LY'

>>> format_full_name("alfred thanh phuc", "pham", Locale('fra'))
'Alfred Thanh Phuc PHAM'
>>> format_full_name("alfred thanh phuc", "pham", Locale('vie'))
'PHAM Alfred Thanh Phuc'

>>> format_full_name("alfred", "pham", Locale('vie'), full_name="pham thanh phuc")
ValueError: None of the first name words has been found in the full name
>>> format_full_name("alfred phuc", "pham", Locale('fra'), full_name="pham thanh phuc")
ValueError: The parts of the full name are not written in the expected order
>>> format_full_name("alfred phuc", "pham", Locale('fra'), full_name="alfred thanh phuc pham")
'Alfred Thanh Phuc PHAM'
>>> format_full_name("alfred phuc", "pham", Locale('vie'), full_name="Phạm thanh phúc alfred")
'PHẠM Thanh Phúc Alfred'

>>> # If a last name is composed of two or more words, while the full name
>>> # follows western lexical order, this two or more words SHOULD be 
>>> # in the full name (otherwise the function won't be able to determine
>>> # included in the full name, but not necessary.
>>> format_full_name("Aline", "Caune ly", Locale('fra'), full_name="aline minh anh maria caune ly")  # OK
'Aline Minh Anh Maria CAUNE LY'
>>> format_full_name("Aline", "Caune", Locale('fra'), full_name="aline minh anh maria caune ly")  # Still OK, even if incoherent input
'Aline Minh Anh Maria CAUNE LY'

>>> format_full_name("truc", "nguyen", Locale('vie'), full_name="nguyen thi thanh truc maria")
'NGUYEN Thi Thanh Truc Maria'

>>> # If a last name is composed of two or more words, while the full name
>>> # follows eastern lexical order, this two or more words MUST be included
>>> # in the full name (otherwise the function won't be able to determine
>>> # which parts of the name correspond to the last name or to the 
>>> # possible middle name).
>>> format_full_name("Thao nguyen", "nguyen le", Locale('vie'), "Nguyễn Lê thị Thảo Nguyên")
'NGUYỄN LÊ Thị Thảo Nguyên'  # OK
>>> format_full_name("Thao nguyen", "nguyen le", Locale('vie'), "Nguyễn thị Thảo Nguyên")  # Still OK, even if incoherent input
'NGUYỄN Thị Thảo Nguyên'
>>> format_full_name("Thao nguyen", "nguyen", Locale('vie'), "Nguyễn Lê thị Thảo Nguyên")  # Not OK! Part of the last name is missing.
'NGUYỄN Lê Thị Thảo Nguyên'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prosoponym-1.2.3.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prosoponym-1.2.3-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file prosoponym-1.2.3.tar.gz.

File metadata

  • Download URL: prosoponym-1.2.3.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Darwin/23.2.0

File hashes

Hashes for prosoponym-1.2.3.tar.gz
Algorithm Hash digest
SHA256 e97845a95dce80c95c0449f1f61e58f158f90f92049be6454c878c29b7948d62
MD5 65e3c25ab26c0bdf713531e0f748218b
BLAKE2b-256 629384c759576de598cfc2ee0077a67b23ee44c04311927981f80da9d9a72252

See more details on using hashes here.

File details

Details for the file prosoponym-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: prosoponym-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Darwin/23.2.0

File hashes

Hashes for prosoponym-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1a53d5df7fde7f1f4d62ff6a59958f439311f989a15e203acb06d87582fe8dbd
MD5 4a06777bee0bde60188c420f27a8ff2d
BLAKE2b-256 2c262fe03ba428c2761a38da0802eaf571b1592d97cbf36b45226660e8f26465

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page