Skip to main content

Name parser

Project description

Parsernaam: Predict First and Last Name

https://github.com/appeler/parsernaam/actions/workflows/python-package.yml/badge.svg https://img.shields.io/pypi/v/parsernaam.svg https://static.pepy.tech/badge/parsernaam

Most common name parsers use crude pattern matching and the sequence of strings, e.g., the last word is the last name, to parse names. This approach is limited and fragile, especially for Indian names. We take a machine-learning approach to the problem. Using the large voter registration data in India and US, we build machine-learning-based name parsers that predict whether the string is a first or last name.

For Indian electoral rolls, we assume the last name is the word in the name that is shared by multiple family members. (We table the expansion to include compound last names—extremely rare in India—till the next iteration.)

Gradio App.

parsernaam on HF

Installation

pip install parsernaam

General API

The general API is as follows:

# Import the library
from parsernaam.parsernaam import ParseNames

positional arguments:
  df                 dataframe with Names to parse (with column name 'name')

# example
df = pd.DataFrame({'name': ['Jan Petersen', 'Piet', 'Janssen']})
           name                                                                                                                       parsed_name
0  Jan Petersen  [{'name': 'Jan', 'type': 'first', 'prob': 0.6769440174102783}, {'name': 'Petersen', 'type': 'last', 'prob': 0.5342262387275696}]
1          Piet                                                                   [{'name': 'Piet', 'type': 'first', 'prob': 0.5381495952606201}]
2       Janssen                                                                [{'name': 'Janssen', 'type': 'first', 'prob': 0.5929554104804993}]

Data

The model is trained on names from the Florida Voter Registration Data from early 2022. The data are available on the Harvard Dataverse

Authors

Rajashekar Chintalapati and Gaurav Sood

Contributing

Contributions are welcome. Please open an issue if you find a bug or have a feature request.

License

The package is released under the MIT License.

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

parsernaam-0.0.3.tar.gz (4.1 MB view details)

Uploaded Source

Built Distribution

parsernaam-0.0.3-py2.py3-none-any.whl (4.1 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file parsernaam-0.0.3.tar.gz.

File metadata

  • Download URL: parsernaam-0.0.3.tar.gz
  • Upload date:
  • Size: 4.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for parsernaam-0.0.3.tar.gz
Algorithm Hash digest
SHA256 718f34e9583eed00933e079fe7136abda43b79a2b2f66e15e8346e016645e494
MD5 9da89536c3648b1ec6fb262d188d7ec5
BLAKE2b-256 9b4ba7d0211a2cfcbe46f43c84c74ade76efe26cb0a35d6260705c429b7680ec

See more details on using hashes here.

File details

Details for the file parsernaam-0.0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: parsernaam-0.0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for parsernaam-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3c41189050b380e5257ba1ddd9729925ae8dbd4983db0ced151dce3f0f3abfd3
MD5 2a5b8811978999fff8205f1da41d4b18
BLAKE2b-256 27d1a0b39feb4e641f47fac2c4e337a4139682948b02da7161bb5d238037e551

See more details on using hashes here.

Supported by

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