Skip to main content

A simple Python module for parsing human names into their individual components.

Project description

A simple Python module for parsing human names into their individual components. The HumanName class splits a name string up into name parts based on placement in the string and matches against known name pieces like titles. It joins name pieces on conjunctions and special prefixes to last names like “del”. Titles can be chained together and include conjunctions to handle titles like “Asst Secretary of State”. It can also try to correct capitalization.

It attempts the best guess that can be made with a simple, rule-based approach. It’s not perfect, but it gets you pretty far.

Usage Example

>>> from nameparser import HumanName
>>> name = HumanName("Dr. Juan Q. Xavier de la Vega III (Doc Vega)")
>>> name
<HumanName : [
    title: 'Dr.'
    first: 'Juan'
    middle: 'Q. Xavier'
    last: 'de la Vega'
    suffix: 'III'
    nickname: 'Doc Vega'
]>
>>> name.last
u'de la Vega'
>>> name.as_dict()
{u'last': u'de la Vega', u'suffix': u'III', u'title': u'Dr.', u'middle': u'Q. Xavier', u'nickname': u'Doc Vega', u'first': u'Juan'}

Unit Tests

Over 100 unit tests with example names. Start a New Issue for names that fail and I will try to fix it.

Installation

pip install nameparser

I usually push changes to PyPi pretty quickly. If you want to try out the latest code from GitHub you can install with pip using the command below.

pip install -e git+git://github.com/derek73/python-nameparser.git#egg=nameparser

If you’re looking for a web service, check out eyeseast’s nameparse service, a simple Heroku-friendly Flask wrapper for this module.

Documentation

http://nameparser.readthedocs.org/en/latest/

NOTE: This documentation covers the new version 0.3. For the v0.2.10 documentation, see the v0.2.10 tag on GitHub.

Contributing

If you come across name piece that you think should be in the default config, you’re probably right. Start a New Issue and we can get them added.

Or, use GitHub’s nifty web interface to add your new pieces directly to the config files and create a pull request all in one go, no fork needed. As an example, click here to propose changes to the titles config.

Please let me know if there are ways this library could be restructured to make it easier for you to use in your projects. Read CONTRIBUTING.md for more info on running the tests and contributing to the project.

GitHub Project

https://github.com/derek73/python-nameparser

Project details


Release history Release notifications

History Node

0.5.6

History Node

0.5.5

History Node

0.5.4

History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.1

History Node

0.4.0

History Node

0.3.16

History Node

0.3.15

History Node

0.3.14

History Node

0.3.13

History Node

0.3.12

History Node

0.3.11

History Node

0.3.10

History Node

0.3.9

History Node

0.3.8

History Node

0.3.7

History Node

0.3.6

History Node

0.3.5

History Node

0.3.4

History Node

0.3.3

History Node

0.3.2

History Node

0.3.1

This version
History Node

0.3.0

History Node

0.2.10

History Node

0.2.9

History Node

0.2.8

History Node

0.2.7

History Node

0.2.6

History Node

0.2.5

History Node

0.2.4

History Node

0.2.3

History Node

0.2.2

History Node

0.2.0

History Node

0.1.4

History Node

0.1.3

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
nameparser-0.3.0.tar.gz (9.4 kB) Copy SHA256 hash SHA256 Source None Jul 4, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page