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.4.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: prosoponym-1.2.4.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.5.0

File hashes

Hashes for prosoponym-1.2.4.tar.gz
Algorithm Hash digest
SHA256 a059393cc90d3360ab1d0626fe623bc20c998a76c64ad1f2f109d485c3ba796b
MD5 0d39a7dfdf1113792dfb445168e67993
BLAKE2b-256 fe088b1fadb88651aa6ebdd59e38054ce0fab93829a941085355f4c427344607

See more details on using hashes here.

File details

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

File metadata

  • Download URL: prosoponym-1.2.4-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.5.0

File hashes

Hashes for prosoponym-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 47b0a514469b6ec5e5c188ca9e8eb8bab56e4627ed57ee4a26fcd8135a711f50
MD5 e38234155d097d351a8f12f53db74087
BLAKE2b-256 6a6cc0d11517b28d66af76581801d2a2148a8adefbf7b6d2f73430a1deb5fa6b

See more details on using hashes here.

Supported by

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