nameparser 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
nameparser/py.typed ADDED
File without changes
nameparser/util.py ADDED
@@ -0,0 +1,17 @@
1
+ import logging
2
+ from typing import Literal
3
+
4
+ # http://code.google.com/p/python-nameparser/issues/detail?id=10
5
+ log = logging.getLogger('HumanName')
6
+ log.addHandler(logging.NullHandler())
7
+ log.setLevel(logging.ERROR)
8
+
9
+
10
+ HumanNameAttributeT = Literal['title', 'first', 'middle', 'last', 'suffix', 'nickname', 'surnames']
11
+
12
+
13
+ def lc(value: str) -> str:
14
+ """Lower case and remove any periods to normalize for comparison."""
15
+ if not value:
16
+ return ''
17
+ return value.lower().strip('.')
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: nameparser
3
+ Version: 1.2.0
4
+ Summary: A simple Python module for parsing human names into their individual components.
5
+ Author-email: Derek Gulbranson <derek73@gmail.com>
6
+ License: LGPL
7
+ Keywords: names,parser
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Development Status :: 5 - Production/Stable
19
+ Classifier: Natural Language :: English
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: Text Processing :: Linguistic
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/x-rst
24
+ License-File: LICENSE
25
+ License-File: AUTHORS
26
+ Requires-Dist: typing_extensions>=4.5.0; python_version < "3.11"
27
+ Dynamic: license-file
28
+
29
+ Name Parser
30
+ ===========
31
+
32
+ |Build Status| |PyPI| |PyPI version| |Documentation|
33
+
34
+ A simple Python (3.10+) module for parsing human names into their
35
+ individual components.
36
+
37
+ * hn.title
38
+ * hn.first
39
+ * hn.middle
40
+ * hn.last
41
+ * hn.suffix
42
+ * hn.nickname
43
+ * hn.surnames *(middle + last)*
44
+ * hn.initials *(first initial of each name part)*
45
+
46
+ Supported Name Structures
47
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
48
+
49
+ The supported name structure is generally "Title First Middle Last Suffix", where all pieces
50
+ are optional. Comma-separated format like "Last, First" is also supported.
51
+
52
+ 1. Title Firstname "Nickname" Middle Middle Lastname Suffix
53
+ 2. Lastname [Suffix], Title Firstname (Nickname) Middle Middle[,] Suffix [, Suffix]
54
+ 3. Title Firstname M Lastname [Suffix], Suffix [Suffix] [, Suffix]
55
+
56
+ Instantiating the `HumanName` class with a string splits on commas and then spaces,
57
+ classifying name parts based on placement in the string and matches against known name
58
+ pieces like titles and suffixes.
59
+
60
+ It correctly handles some common conjunctions and special prefixes to last names
61
+ like "del". Titles and conjunctions can be chained together to handle complex
62
+ titles like "Asst Secretary of State". It can also try to correct capitalization
63
+ of names that are all upper- or lowercase names.
64
+
65
+ It attempts the best guess that can be made with a simple, rule-based approach.
66
+ Its main use case is English and it is not likely to be useful for languages
67
+ that do not conform to the supported name structure. It's not perfect, but it
68
+ gets you pretty far.
69
+
70
+ Installation
71
+ ------------
72
+
73
+ ::
74
+
75
+ pip install nameparser
76
+
77
+ If you want to try out the latest code from GitHub you can
78
+ install with pip using the command below.
79
+
80
+ ``pip install -e git+https://github.com/derek73/python-nameparser.git``
81
+
82
+ If you need to handle lists of names, check out
83
+ `namesparser <https://github.com/gwu-libraries/namesparser>`_, a
84
+ compliment to this module that handles multiple names in a string.
85
+
86
+
87
+ Quick Start Example
88
+ -------------------
89
+
90
+ ::
91
+
92
+ >>> from nameparser import HumanName
93
+ >>> name = HumanName("Dr. Juan Q. Xavier de la Vega III (Doc Vega)")
94
+ >>> name
95
+ <HumanName : [
96
+ title: 'Dr.'
97
+ first: 'Juan'
98
+ middle: 'Q. Xavier'
99
+ last: 'de la Vega'
100
+ suffix: 'III'
101
+ nickname: 'Doc Vega'
102
+ ]>
103
+ >>> name.last
104
+ 'de la Vega'
105
+ >>> name.as_dict()
106
+ {'last': 'de la Vega', 'suffix': 'III', 'title': 'Dr.', 'middle': 'Q. Xavier', 'nickname': 'Doc Vega', 'first': 'Juan'}
107
+ >>> str(name)
108
+ 'Dr. Juan Q. Xavier de la Vega III (Doc Vega)'
109
+ >>> name.string_format = "{first} {last}"
110
+ >>> str(name)
111
+ 'Juan de la Vega'
112
+
113
+
114
+ The parser does not attempt to correct mistakes in the input. It mostly just splits on white
115
+ space and puts things in buckets based on their position in the string. This also means
116
+ the difference between 'title' and 'suffix' is positional, not semantic. "Dr" is a title
117
+ when it comes before the name and a suffix when it comes after. ("Pre-nominal"
118
+ and "post-nominal" would probably be better names.)
119
+
120
+ ::
121
+
122
+ >>> name = HumanName("1 & 2, 3 4 5, Mr.")
123
+ >>> name
124
+ <HumanName : [
125
+ title: ''
126
+ first: '3'
127
+ middle: '4 5'
128
+ last: '1 & 2'
129
+ suffix: 'Mr.'
130
+ nickname: ''
131
+ ]>
132
+
133
+ Customization
134
+ -------------
135
+
136
+ Your project may need some adjustment for your dataset. You can
137
+ do this in your own pre- or post-processing, by `customizing the configured pre-defined
138
+ sets`_ of titles, prefixes, etc., or by subclassing the `HumanName` class. See the
139
+ `full documentation`_ for more information.
140
+
141
+
142
+ `Full documentation`_
143
+ ~~~~~~~~~~~~~~~~~~~~~
144
+
145
+ .. _customizing the configured pre-defined sets: http://nameparser.readthedocs.org/en/latest/customize.html
146
+ .. _Full documentation: http://nameparser.readthedocs.org/en/latest/
147
+
148
+
149
+ Contributing
150
+ ------------
151
+
152
+ If you come across name piece that you think should be in the default config, you're
153
+ probably right. `Start a New Issue`_ and we can get them added.
154
+
155
+ Please let me know if there are ways this library could be structured to make
156
+ it easier for you to use in your projects. Read CONTRIBUTING.md_ for more info
157
+ on running the tests and contributing to the project.
158
+
159
+ **GitHub Project**
160
+
161
+ https://github.com/derek73/python-nameparser
162
+
163
+ .. _CONTRIBUTING.md: https://github.com/derek73/python-nameparser/tree/master/CONTRIBUTING.md
164
+ .. _Start a New Issue: https://github.com/derek73/python-nameparser/issues
165
+ .. _click here to propose changes to the titles: https://github.com/derek73/python-nameparser/edit/master/nameparser/config/titles.py
166
+
167
+ .. |Build Status| image:: https://github.com/derek73/python-nameparser/actions/workflows/python-package.yml/badge.svg
168
+ :target: https://github.com/derek73/python-nameparser/actions/workflows/python-package.yml
169
+ .. |PyPI| image:: https://img.shields.io/pypi/v/nameparser.svg
170
+ :target: https://pypi.org/project/nameparser/
171
+ .. |Documentation| image:: https://readthedocs.org/projects/nameparser/badge/?version=latest
172
+ :target: http://nameparser.readthedocs.io/en/latest/?badge=latest
173
+ .. |PyPI version| image:: https://img.shields.io/pypi/pyversions/nameparser.svg
174
+ :target: https://pypi.org/project/nameparser/
@@ -0,0 +1,18 @@
1
+ nameparser/__init__.py,sha256=u5lKOsn4fZ9ldPcx72s86XkDxTg6gF_KtlLDcm3eyfw,312
2
+ nameparser/_version.py,sha256=mGi0_w34ITeMByNC6CbD7lrByXEilMGomtRGIAfkyY4,62
3
+ nameparser/parser.py,sha256=37PjjrfoVowRjVNxeekX3sH3O42cRtFBhUO7J_0BFtU,38385
4
+ nameparser/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ nameparser/util.py,sha256=99v8cudNuunZq30H4zBQwAmZraHf2NzGJy1ueVTqa10,487
6
+ nameparser/config/__init__.py,sha256=OrVQo7jpjwvocDsaZYJiGNDKWwDM8kHgPbz5Yso7uJU,9812
7
+ nameparser/config/capitalization.py,sha256=W0xv4zqK2WkqOyqoNZ6xvW4nb7t1NZtJuSZq-SOxCtE,208
8
+ nameparser/config/conjunctions.py,sha256=D0DXBP0fDax2znPdAaB0880t83kUKpKYi-blMFcJWbM,300
9
+ nameparser/config/prefixes.py,sha256=JUb9BDCGIl7jl119u9X4E8DhpiqftEdA6Uhd2ixdurg,1101
10
+ nameparser/config/regexes.py,sha256=n9uuExgOqene-sfRfWwhqZGwWSQaUZFcCLrob_MQUTk,1080
11
+ nameparser/config/suffixes.py,sha256=HHVdtXrZ_Kg9jOfJlzxVgiEgmwY8mJVzMERZpZbywMs,7835
12
+ nameparser/config/titles.py,sha256=qaABn1ho8HVHJ3qRq58FwoZEfexKQ-nLvIqK7iagHZY,9741
13
+ nameparser-1.2.0.dist-info/licenses/AUTHORS,sha256=W_1fAEdV7KOJh_psX1KZmJ7iLfDI_VKBIbKb9Eex21M,37
14
+ nameparser-1.2.0.dist-info/licenses/LICENSE,sha256=EfTd-9HWXojdqvJ56lmKf9Z3sJH-vPiPcYskM7PhFyU,637
15
+ nameparser-1.2.0.dist-info/METADATA,sha256=ORyGg3ci7v2sd9X_40e9uCL90BrkB59bkai1Oc3mLBE,6290
16
+ nameparser-1.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
17
+ nameparser-1.2.0.dist-info/top_level.txt,sha256=ymOIbs7a20R7EVL7_0LNZrwshcEmPbueeKYI4je38Oo,11
18
+ nameparser-1.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ Derek Gulbranson <derek73@gmail.com>
@@ -0,0 +1,16 @@
1
+ Copyright Derek Gulbranson <derek73 at gmail>.
2
+ http://derekgulbranson.com/
3
+
4
+ -----
5
+
6
+ LGPL-2.1+
7
+ http://www.opensource.org/licenses/lgpl-license.html
8
+
9
+ This library is free software; you can redistribute it and/or modify it under the
10
+ terms of the GNU Lesser General Public License as published by the Free Software
11
+ Foundation; either version 2.1 of the License, or (at your option) any later
12
+ version.
13
+
14
+ This library is distributed in the hope that it will be useful, but WITHOUT ANY
15
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
16
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
@@ -0,0 +1 @@
1
+ nameparser