pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/derek73/python-nameparser/commit/7d8aea82815486e5b773c57ed2ec92ca3a60af52

"anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> Speed up parsing by about 2x on average, fix __getitem__(), and use s… · derek73/python-nameparser@7d8aea8 · GitHub
Skip to content

Commit 7d8aea8

Browse files
committed
Speed up parsing by about 2x on average, fix __getitem__(), and use setuptools if available.
1 parent 280895b commit 7d8aea8

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

nameparser/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (0, 1, 3)
1+
VERSION = (0, 1, 4)
22
__version__ = '.'.join(map(str, VERSION))
33
__author__ = "Derek Gulbranson"
44
__author_email__ = 'derek73@gmail.com'

nameparser/constants.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
re_mac = re.compile(r'^(ma?c)(\w)', re.I)
66
re_initial = re.compile(r'^(\w\.|[A-Z])?$')
77

8-
TITLES = (
8+
TITLES = set([
99
'dr','doctor','miss','misses','mr','mister','mrs','ms','sir',
1010
'rev','madam','madame','AB','2ndLt','Amn','1stLt','A1C','Capt','SrA','Maj',
1111
'SSgt','LtCol','TSgt','Col','BrigGen','1stSgt','MajGen','SMSgt','LtGen',
@@ -19,7 +19,7 @@
1919
'Gen','SgtMaj','SgtMajMC','WO-1','CWO-2','CWO-3','CWO-4','CWO-5','ENS','SA',
2020
'LTJG','SN','LT','PO3','LCDR','PO2','CDR','PO1','CAPT','CPO','RDML','SCPO',
2121
'RADM','MCPO','VADM','MCPON','ADM','FADM','WO1','CWO2','CWO3','CWO4','CWO5'
22-
)
22+
])
2323

2424
# QUESTIONABLE_TITLES could be last names or they could be titles.
2525
# TODO: need to find best way to deal with these, not doing anything special yet.
@@ -28,20 +28,20 @@
2828

2929
# PUNC_TITLES could be names or titles, but if they have period at the end they're a title
3030
PUNC_TITLES = ('hon.',)
31-
PREFICES = (
31+
PREFICES = set([
3232
'abu','bon','ben','bin','da','dal','de','del','der','de','di','e','ibn',
3333
'la','le','san','st','ste','van','vel','von'
34-
)
35-
SUFFICES = (
34+
])
35+
SUFFICES = set([
3636
'esq','esquire','jr','sr','2','i','ii','iii','iv','v','clu','chfc',
3737
'cfp','md','phd'
38-
)
38+
])
3939
CAPITALIZATION_EXCEPTIONS = {
4040
'ii': 'II',
4141
'iii': 'III',
4242
'iv': 'IV',
4343
'md': 'M.D.',
4444
'phd': 'Ph.D.'
4545
}
46-
CONJUNCTIONS = ('&', 'and', 'et', 'e', 'und', 'y')
46+
CONJUNCTIONS = set(['&', 'and', 'et', 'e', 'und', 'y'])
4747

nameparser/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def __ne__(self, other):
113113
return not unicode(self).lower() == unicode(other).lower()
114114

115115
def __getitem__(self, key):
116-
return [getattr(self, x) for x in self.members[key]]
116+
return getattr(self, self.members[key])
117117

118118
def next(self):
119119
if self.count >= len(self.members):

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env python
2-
from distutils.core import setup
2+
try:
3+
from setuptools import setup
4+
except ImportError:
5+
from distutils.core import setup
36
import nameparser
47
import os
58

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy