From c6f94a1be9a9c8a9122b453a2ac5bc1ccb6ef5b5 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Mon, 3 Jan 2022 20:50:17 -0800 Subject: [PATCH 01/27] update badge --- README.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.rst b/README.rst index b347593..ee0c152 100644 --- a/README.rst +++ b/README.rst @@ -136,8 +136,7 @@ https://github.com/derek73/python-nameparser .. _click here to propose changes to the titles: https://github.com/derek73/python-nameparser/edit/master/nameparser/config/titles.py -.. |Build Status| image:: https://travis-ci.org/derek73/python-nameparser.svg?branch=master - :target: https://travis-ci.org/derek73/python-nameparser +.. [![Tests](https://github.com/derek73/python-nameparser/actions/workflows/python-package.yml/badge.svg)](https://github.com/derek73/python-nameparser/actions/workflows/python-package.yml) .. |PyPI| image:: https://img.shields.io/pypi/v/nameparser.svg :target: https://pypi.org/project/nameparser/ .. |Documentation| image:: https://readthedocs.org/projects/nameparser/badge/?version=latest From 3700dec4d0a95533a7e9cbc9f814b542ad5255d3 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Mon, 3 Jan 2022 20:52:38 -0800 Subject: [PATCH 02/27] update badge --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ee0c152..effc51b 100644 --- a/README.rst +++ b/README.rst @@ -135,8 +135,8 @@ https://github.com/derek73/python-nameparser .. _Start a New Issue: https://github.com/derek73/python-nameparser/issues .. _click here to propose changes to the titles: https://github.com/derek73/python-nameparser/edit/master/nameparser/config/titles.py - -.. [![Tests](https://github.com/derek73/python-nameparser/actions/workflows/python-package.yml/badge.svg)](https://github.com/derek73/python-nameparser/actions/workflows/python-package.yml) +.. |Build Status| image:: https://github.com/derek73/python-nameparser/actions/workflows/python-package.yml/badge.svg + :target: https://github.com/derek73/python-nameparser/actions/workflows/python-package.yml .. |PyPI| image:: https://img.shields.io/pypi/v/nameparser.svg :target: https://pypi.org/project/nameparser/ .. |Documentation| image:: https://readthedocs.org/projects/nameparser/badge/?version=latest From e9aef6a7ae050f63efadf447e88b5964420392ad Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Mon, 3 Jan 2022 20:59:09 -0800 Subject: [PATCH 03/27] Update README.rst --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index effc51b..11db547 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,7 @@ individual components. * hn.suffix * hn.nickname * hn.surnames *(middle + last)* +* hn.initials *first initial of each name part+ Supported Name Structures ~~~~~~~~~~~~~~~~~~~~~~~~~ From da1bbc8ee1b1d82e0ff23c13c6165c3e75f9f381 Mon Sep 17 00:00:00 2001 From: huangwf0119 <73567665+huangwf0119@users.noreply.github.com> Date: Fri, 28 Jan 2022 15:59:41 +0800 Subject: [PATCH 04/27] Fix one bug in HumanName.is_suffix --- nameparser/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nameparser/parser.py b/nameparser/parser.py index 35f4135..bff64e2 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -416,8 +416,8 @@ def is_suffix(self, piece): """ # suffixes may have periods inside them like "M.D." if isinstance(piece, list): - for piece in pieces: - if self.is_suffix(piece): + for item in piece: + if self.is_suffix(item): return True else: return ((lc(piece).replace('.', '') in self.C.suffix_acronyms) From 993f7aa3c89d65165dc4b3095a2d32a2ffccb182 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Fri, 28 Jan 2022 01:24:04 -0800 Subject: [PATCH 05/27] version 1.1.1 --- docs/release_log.rst | 2 ++ nameparser/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/release_log.rst b/docs/release_log.rst index 57b7bf5..f89b8a7 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -1,5 +1,7 @@ Release Log =========== +* 1.1.1 - January 28, 2022 + - Fix bug in is_suffix handling of lists (#128) * 1.1.0 - January 3, 2022 - Add initials support (#128) - Add more titles and prefixes (#120, #127, #128, #119) diff --git a/nameparser/__init__.py b/nameparser/__init__.py index a9ee753..6439529 100644 --- a/nameparser/__init__.py +++ b/nameparser/__init__.py @@ -1,4 +1,4 @@ -VERSION = (1, 1, 0) +VERSION = (1, 1, 1) __version__ = '.'.join(map(str, VERSION)) __author__ = "Derek Gulbranson" __author_email__ = 'derek73@gmail.com' From c44a281e671fec49cf66d8ccc3bea28099f0653f Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Fri, 28 Jan 2022 01:25:34 -0800 Subject: [PATCH 06/27] typo --- docs/release_log.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release_log.rst b/docs/release_log.rst index f89b8a7..954d992 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -1,7 +1,7 @@ Release Log =========== * 1.1.1 - January 28, 2022 - - Fix bug in is_suffix handling of lists (#128) + - Fix bug in is_suffix handling of lists (#129) * 1.1.0 - January 3, 2022 - Add initials support (#128) - Add more titles and prefixes (#120, #127, #128, #119) From 265d2b3b9611b41060ac550c85911be95ed7ca5b Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Fri, 28 Jan 2022 18:26:30 -0800 Subject: [PATCH 07/27] fix rst formatting error --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 11db547..eebde5b 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,7 @@ individual components. * hn.suffix * hn.nickname * hn.surnames *(middle + last)* -* hn.initials *first initial of each name part+ +* hn.initials *(first initial of each name part)* Supported Name Structures ~~~~~~~~~~~~~~~~~~~~~~~~~ From 95dc27b36c84e1d76b1ee5f7d74c815c0134fb86 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Fri, 28 Jan 2022 18:45:07 -0800 Subject: [PATCH 08/27] add content type for readme --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index ba0cc5a..2067716 100755 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ def read(fname): packages = ['nameparser','nameparser.config'], description = 'A simple Python module for parsing human names into their individual components.', long_description = README, + long_description_content_type = "text/x-rst", version = nameparser.__version__, url = nameparser.__url__, author = nameparser.__author__, From 75fba9b3eada82151fccc8ed1f9f957b28d7a90e Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Fri, 28 Jan 2022 18:48:12 -0800 Subject: [PATCH 09/27] check package can build too --- .github/workflows/python-package.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 721acaa..d47e569 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -27,7 +27,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install twine if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi - name: Run Tests run: | python tests.py + python setup.py sdist bdist_wheel + twine check dist/* From 3077ad5efdc696649cf5cc6371cbdc6608feebe8 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Fri, 28 Jan 2022 18:52:59 -0800 Subject: [PATCH 10/27] only build source dist --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index d47e569..ea0bfa7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -32,5 +32,5 @@ jobs: - name: Run Tests run: | python tests.py - python setup.py sdist bdist_wheel + python setup.py sdist twine check dist/* From f1dff67cbf13697dad6cfd07c27da251b9030f03 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Fri, 28 Jan 2022 19:31:45 -0800 Subject: [PATCH 11/27] silence error about duplicate index --- docs/modules.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/modules.rst b/docs/modules.rst index eaf3240..2056330 100644 --- a/docs/modules.rst +++ b/docs/modules.rst @@ -7,6 +7,7 @@ HumanName.parser .. py:module:: nameparser.parser .. py:class:: HumanName + :noindex: .. autoclass:: HumanName :members: From dc53c0e64276540d87a930420a4eb123cdb5c961 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Fri, 28 Jan 2022 19:35:31 -0800 Subject: [PATCH 12/27] test that the docs build with sphinx --- .github/workflows/python-package.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index ea0bfa7..5ad4ce0 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -28,9 +28,11 @@ jobs: run: | python -m pip install --upgrade pip pip install twine + pip install sphinx if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi - name: Run Tests run: | python tests.py python setup.py sdist twine check dist/* + sphinx-build -b html docs dist/docs From 8b73ff9e0aed23285f451cfa7091e47e9835a608 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Fri, 28 Jan 2022 19:40:34 -0800 Subject: [PATCH 13/27] use pip from python binary --- .github/workflows/python-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 5ad4ce0..cf60638 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -27,8 +27,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install twine - pip install sphinx + python -m pip install twine + python -m pip install sphinx if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi - name: Run Tests run: | From 8144083eac5a7871101bafcd6ba289d402ca30f8 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 1 Feb 2022 15:27:33 +0000 Subject: [PATCH 14/27] Correct a spelling mistake --- nameparser/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nameparser/parser.py b/nameparser/parser.py index bff64e2..5e3f32f 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -191,7 +191,7 @@ def as_dict(self, include_empty=True): def __process_initial__(self, name_part, firstname=False): """ - Name parts may include prefixes or conjuctions. This function filters these from the name unless it is + Name parts may include prefixes or conjunctions. This function filters these from the name unless it is a first name, since first names cannot be conjunctions or prefixes. """ parts = name_part.split(" ") From 42292eb4b9a026afbb81f47b647a03a079b71f39 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Mon, 7 Feb 2022 19:26:13 -0800 Subject: [PATCH 15/27] don't test is_title() if there's a first name --- nameparser/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nameparser/parser.py b/nameparser/parser.py index bff64e2..edeedc5 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -641,9 +641,9 @@ def parse_full_name(self): except IndexError: nxt = None - if self.is_title(piece) \ + if not self.first \ and (nxt or len(pieces) == 1) \ - and not self.first: + and self.is_title(piece): self.title_list.append(piece) continue if not self.first: From 5b1b88da5e6962d1adb9ab56a09928a7250bf6e4 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Mon, 7 Feb 2022 19:27:39 -0800 Subject: [PATCH 16/27] don't test is_title() if there's a first name --- nameparser/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nameparser/parser.py b/nameparser/parser.py index d34af4e..162b044 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -681,9 +681,9 @@ def parse_full_name(self): except IndexError: nxt = None - if self.is_title(piece) \ + if not self.first \ and (nxt or len(post_comma_pieces) == 1) \ - and not self.first: + and self.is_title(piece): self.title_list.append(piece) continue if not self.first: From ab8e5b51c9da92dabdab47fbf12b9487818464d1 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Mon, 7 Feb 2022 19:31:50 -0800 Subject: [PATCH 17/27] don't test is_title() if there's a first name --- nameparser/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nameparser/parser.py b/nameparser/parser.py index 162b044..2ee146c 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -591,9 +591,9 @@ def parse_full_name(self): nxt = None # title must have a next piece, unless it's just a title - if self.is_title(piece) \ + if not self.first \ and (nxt or p_len == 1) \ - and not self.first: + and self.is_title(piece): self.title_list.append(piece) continue if not self.first: From caec4ab12cb1d55205d3eb82d2b35ad7174ac901 Mon Sep 17 00:00:00 2001 From: Pavel T Date: Thu, 29 Sep 2022 11:47:39 -0400 Subject: [PATCH 18/27] fix HumanName repr for names with single quotes eg `HumanName("O'NEILL")` --- nameparser/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nameparser/parser.py b/nameparser/parser.py index 2ee146c..5d15fe7 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -150,7 +150,7 @@ def __repr__(self): if self.unparsable: _string = "<%(class)s : [ Unparsable ] >" % {'class': self.__class__.__name__, } else: - _string = "<%(class)s : [\n\ttitle: '%(title)s' \n\tfirst: '%(first)s' \n\tmiddle: '%(middle)s' \n\tlast: '%(last)s' \n\tsuffix: '%(suffix)s'\n\tnickname: '%(nickname)s'\n]>" % { + _string = "<%(class)s : [\n\ttitle: %(title)r \n\tfirst: %(first)r \n\tmiddle: %(middle)r \n\tlast: %(last)r \n\tsuffix: %(suffix)r\n\tnickname: %(nickname)r\n]>" % { 'class': self.__class__.__name__, 'title': self.title or '', 'first': self.first or '', From 593d2c44d36d09e24f32ee8a3ce4492320b05092 Mon Sep 17 00:00:00 2001 From: moomoohk Date: Wed, 5 Oct 2022 22:45:34 +0300 Subject: [PATCH 19/27] Make HumanName objects hashable --- nameparser/parser.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nameparser/parser.py b/nameparser/parser.py index 2ee146c..bb19fb6 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -141,6 +141,9 @@ def __unicode__(self): return self.collapse_whitespace(_s).strip(', ') return " ".join(self) + def __hash__(self): + return hash(str(self)) + def __str__(self): if sys.version_info[0] >= 3: return self.__unicode__() From 3ae1f2a7100ed4f7c29b06b682665ff3a9494688 Mon Sep 17 00:00:00 2001 From: moomoohk Date: Wed, 5 Oct 2022 22:51:40 +0300 Subject: [PATCH 20/27] Update python-package.yml --- .github/workflows/python-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index cf60638..98c83f8 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -4,6 +4,7 @@ name: Test the Python package on: + workflow_dispatch: push: branches: [ master ] pull_request: From 0033f390be4d7779aaef5acfbf519dd2d8fe1d71 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sun, 13 Nov 2022 18:45:39 -0800 Subject: [PATCH 21/27] add support for name parts in the constructor, fix #140 --- docs/release_log.rst | 2 ++ nameparser/__init__.py | 2 +- nameparser/parser.py | 28 ++++++++++++++++++++++++---- tests.py | 39 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/docs/release_log.rst b/docs/release_log.rst index 954d992..6430d05 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -1,5 +1,7 @@ Release Log =========== +* 1.1.2 - November 13, 2022 + - Add support for attributes in constructor (#140) * 1.1.1 - January 28, 2022 - Fix bug in is_suffix handling of lists (#129) * 1.1.0 - January 3, 2022 diff --git a/nameparser/__init__.py b/nameparser/__init__.py index 6439529..eb595d6 100644 --- a/nameparser/__init__.py +++ b/nameparser/__init__.py @@ -1,4 +1,4 @@ -VERSION = (1, 1, 1) +VERSION = (1, 1, 2) __version__ = '.'.join(map(str, VERSION)) __author__ = "Derek Gulbranson" __author_email__ = 'derek73@gmail.com' diff --git a/nameparser/parser.py b/nameparser/parser.py index a9874b3..c35f55e 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -36,7 +36,10 @@ class HumanName(object): Instantiation assigns to ``full_name``, and assignment to :py:attr:`full_name` triggers :py:func:`parse_full_name`. After parsing the - name, these instance attributes are available. + name, these instance attributes are available. Alternatively, you can pass + any of the instance attributes to the constructor method and skip the parsing + process. If any of the the instance attributes are passed to the constructor + as keywords, :py:func:`parse_full_name` will not be performed. **HumanName Instance Attributes** @@ -56,6 +59,12 @@ class HumanName(object): :param str string_format: python string formatting :param str initials_format: python initials string formatting :param str initials_delimter: string delimiter for initials + :param str first: first name + :param str middle: middle name + :param str last: last name + :param str title: The title or prenominal + :param str suffix: The suffix or postnominal + :param str nickname: Nicknames """ C = CONSTANTS @@ -77,7 +86,9 @@ class HumanName(object): _full_name = '' def __init__(self, full_name="", constants=CONSTANTS, encoding=DEFAULT_ENCODING, - string_format=None, initials_format=None, initials_delimiter=None): + string_format=None, initials_format=None, initials_delimiter=None, + first=None, middle=None, last=None, title=None, suffix=None, + nickname=None): self.C = constants if type(self.C) is not type(CONSTANTS): self.C = Constants() @@ -86,8 +97,17 @@ def __init__(self, full_name="", constants=CONSTANTS, encoding=DEFAULT_ENCODING, self.string_format = string_format or self.C.string_format self.initials_format = initials_format or self.C.initials_format self.initials_delimiter = initials_delimiter or self.C.initials_delimiter - # full_name setter triggers the parse - self.full_name = full_name + if (first or middle or last or title or suffix or nickname): + self.first = first + self.middle = middle + self.last = last + self.title = title + self.suffix = suffix + self.nickname = nickname + self.unparsable = False + else: + # full_name setter triggers the parse + self.full_name = full_name def __iter__(self): return self diff --git a/tests.py b/tests.py index 91917a4..5eb1c72 100644 --- a/tests.py +++ b/tests.py @@ -2343,7 +2343,44 @@ def test_initials_with_prefix_firstname(self): def test_initials_with_prefix(self): hn = HumanName("Alex van Johnson") self.m(hn.initials_list(), ["A", "J"], hn) - + + def test_constructor_first(self): + hn = HumanName(first="TheName") + self.assertFalse(hn.unparsable) + self.m(hn.first, "TheName", hn) + + def test_constructor_middle(self): + hn = HumanName(middle="TheName") + self.assertFalse(hn.unparsable) + self.m(hn.middle, "TheName", hn) + + def test_constructor_last(self): + hn = HumanName(last="TheName") + self.assertFalse(hn.unparsable) + self.m(hn.last, "TheName", hn) + + def test_constructor_title(self): + hn = HumanName(title="TheName") + self.assertFalse(hn.unparsable) + self.m(hn.title, "TheName", hn) + + def test_constructor_suffix(self): + hn = HumanName(suffix="TheName") + self.assertFalse(hn.unparsable) + self.m(hn.suffix, "TheName", hn) + + def test_constructor_nickname(self): + hn = HumanName(nickname="TheName") + self.assertFalse(hn.unparsable) + self.m(hn.nickname, "TheName", hn) + + def test_constructor_multiple(self): + hn = HumanName(first="TheName", last="lastname", title="mytitle", full_name="donotparse") + self.assertFalse(hn.unparsable) + self.m(hn.first, "TheName", hn) + self.m(hn.last, "lastname", hn) + self.m(hn.title, "mytitle", hn) + TEST_NAMES = ( "John Doe", From c2d07184489ae733ff7dcb6c3e395cf682e7bb5b Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sun, 13 Nov 2022 18:59:30 -0800 Subject: [PATCH 22/27] update release notes and resources --- docs/release_log.rst | 2 ++ docs/resources.rst | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/docs/release_log.rst b/docs/release_log.rst index 6430d05..a6d6aa4 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -2,6 +2,8 @@ Release Log =========== * 1.1.2 - November 13, 2022 - Add support for attributes in constructor (#140) + - Make HumanName instances hashable (#138) + - Update repr for names with single quotes (#137) * 1.1.1 - January 28, 2022 - Fix bug in is_suffix handling of lists (#129) * 1.1.0 - January 3, 2022 diff --git a/docs/resources.rst b/docs/resources.rst index 6cc28e8..8934aae 100644 --- a/docs/resources.rst +++ b/docs/resources.rst @@ -7,6 +7,8 @@ Naming Practices and Resources * Wikipedia_Anthroponymy_ * Wikipedia_Naming_conventions_ * Wikipedia_List_Of_Titles_ + * Tussenvoegsel_ + * Family_Name_Affixes_ .. _US_Census_Surname_Data_2000: https://www.census.gov/data/developers/data-sets/surnames/2000.html .. _US_Social_Security_Administration_Baby_Names_Index: https://www.ssa.gov/oact/babynames/limits.html @@ -14,3 +16,5 @@ Naming Practices and Resources .. _Wikipedia_Anthroponymy: https://en.wikipedia.org/wiki/Anthroponymy .. _Wikipedia_Naming_conventions: http://en.wikipedia.org/wiki/Wikipedia:Naming_conventions_(people) .. _Wikipedia_List_Of_Titles: https://en.wikipedia.org/wiki/Title +.. _Tussenvoegsel: https://en.wikipedia.org/wiki/Tussenvoegsel +.. _Family_Name_Affixes : https://en.wikipedia.org/wiki/List_of_family_name_affixes From 89851f43ef9c09a1459fa87d42a3a2e47816a31e Mon Sep 17 00:00:00 2001 From: Evgeny Liskovets Date: Thu, 14 Sep 2023 12:36:50 -0400 Subject: [PATCH 23/27] Fix case when we have two same prefixes in the name --- nameparser/parser.py | 12 ++++++------ tests.py | 10 +++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/nameparser/parser.py b/nameparser/parser.py index c35f55e..50607f6 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -36,10 +36,10 @@ class HumanName(object): Instantiation assigns to ``full_name``, and assignment to :py:attr:`full_name` triggers :py:func:`parse_full_name`. After parsing the - name, these instance attributes are available. Alternatively, you can pass + name, these instance attributes are available. Alternatively, you can pass any of the instance attributes to the constructor method and skip the parsing - process. If any of the the instance attributes are passed to the constructor - as keywords, :py:func:`parse_full_name` will not be performed. + process. If any of the the instance attributes are passed to the constructor + as keywords, :py:func:`parse_full_name` will not be performed. **HumanName Instance Attributes** @@ -536,9 +536,9 @@ def parse_nicknames(self): Loops through 3 :py:data:`~nameparser.config.regexes.REGEXES`; `quoted_word`, `double_quotes` and `parenthesis`. """ - + empty_re = re.compile("") - + re_quoted_word = self.C.regexes.quoted_word or empty_re re_double_quotes = self.C.regexes.double_quotes or empty_re re_parenthesis = self.C.regexes.parenthesis or empty_re @@ -906,7 +906,7 @@ def join_on_conjunctions(self, pieces, additional_parts_count=0): # If it's the first piece and there are more than 1 rootnames, assume it's a first name continue next_prefix = next(iter(filter(self.is_prefix, pieces[i + 1:]))) - j = pieces.index(next_prefix) + j = pieces.index(next_prefix, i+1) if j == i + 1: # if there are two prefixes in sequence, join to the following piece j += 1 diff --git a/tests.py b/tests.py index 5eb1c72..2760991 100644 --- a/tests.py +++ b/tests.py @@ -2071,6 +2071,10 @@ def test_multiple_prefixes(self): self.m(hn.first, "Mike", hn) self.m(hn.last, "van der Velt", hn) + def test_prefix_as_fist_name(self): + hh = HumanName("Van Ma Van") + self.m(hh.first, "Van Ma", hh) + self.m(hh.last, "Van", hh) class HumanNameCapitalizationTestCase(HumanNameTestBase): def test_capitalization_exception_for_III(self): @@ -2343,12 +2347,12 @@ def test_initials_with_prefix_firstname(self): def test_initials_with_prefix(self): hn = HumanName("Alex van Johnson") self.m(hn.initials_list(), ["A", "J"], hn) - + def test_constructor_first(self): hn = HumanName(first="TheName") self.assertFalse(hn.unparsable) self.m(hn.first, "TheName", hn) - + def test_constructor_middle(self): hn = HumanName(middle="TheName") self.assertFalse(hn.unparsable) @@ -2380,7 +2384,7 @@ def test_constructor_multiple(self): self.m(hn.first, "TheName", hn) self.m(hn.last, "lastname", hn) self.m(hn.title, "mytitle", hn) - + TEST_NAMES = ( "John Doe", From 609be71e72205b6c0719d8eb55386df2218daee0 Mon Sep 17 00:00:00 2001 From: Evgeny Liskovets Date: Thu, 14 Sep 2023 12:45:54 -0400 Subject: [PATCH 24/27] Rename test with better description --- nameparser/parser.py | 2 +- tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nameparser/parser.py b/nameparser/parser.py index 50607f6..a5eb352 100644 --- a/nameparser/parser.py +++ b/nameparser/parser.py @@ -906,7 +906,7 @@ def join_on_conjunctions(self, pieces, additional_parts_count=0): # If it's the first piece and there are more than 1 rootnames, assume it's a first name continue next_prefix = next(iter(filter(self.is_prefix, pieces[i + 1:]))) - j = pieces.index(next_prefix, i+1) + j = pieces.index(next_prefix, i + 1) if j == i + 1: # if there are two prefixes in sequence, join to the following piece j += 1 diff --git a/tests.py b/tests.py index 2760991..be407cc 100644 --- a/tests.py +++ b/tests.py @@ -2071,7 +2071,7 @@ def test_multiple_prefixes(self): self.m(hn.first, "Mike", hn) self.m(hn.last, "van der Velt", hn) - def test_prefix_as_fist_name(self): + def test_2_same_prefixes_in_the_name(self): hh = HumanName("Van Ma Van") self.m(hh.first, "Van Ma", hh) self.m(hh.last, "Van", hh) From ed322da1eb6cfb571118453e0398a9db3b03484f Mon Sep 17 00:00:00 2001 From: Evgeny Liskovets Date: Thu, 14 Sep 2023 18:29:11 -0400 Subject: [PATCH 25/27] Change test --- tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests.py b/tests.py index be407cc..2cdd526 100644 --- a/tests.py +++ b/tests.py @@ -2072,9 +2072,10 @@ def test_multiple_prefixes(self): self.m(hn.last, "van der Velt", hn) def test_2_same_prefixes_in_the_name(self): - hh = HumanName("Van Ma Van") - self.m(hh.first, "Van Ma", hh) - self.m(hh.last, "Van", hh) + hh = HumanName("Vincent van Gogh van Beethoven") + self.m(hh.first, "Vincent", hh) + self.m(hh.middle, "van Gogh", hh) + self.m(hh.last, "van Beethoven", hh) class HumanNameCapitalizationTestCase(HumanNameTestBase): def test_capitalization_exception_for_III(self): From 42a3b7b8ceba9d5d84329970dbbaa3dcb4ce28f2 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 14 Sep 2023 21:28:33 -0700 Subject: [PATCH 26/27] Update to current python versions --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 98c83f8..0cc23c2 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v2 From 759a1316f2fda4395714f36d777fd014dcdd51b0 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Wed, 20 Sep 2023 17:05:34 -0700 Subject: [PATCH 27/27] v1.1.3 update version and release notes --- docs/release_log.rst | 2 ++ nameparser/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/release_log.rst b/docs/release_log.rst index a6d6aa4..a0ab7ee 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -1,5 +1,7 @@ Release Log =========== +* 1.1.3 - September 20, 2023 + - Fix case when we have two same prefixes in the name ()#147) * 1.1.2 - November 13, 2022 - Add support for attributes in constructor (#140) - Make HumanName instances hashable (#138) diff --git a/nameparser/__init__.py b/nameparser/__init__.py index eb595d6..ab914e9 100644 --- a/nameparser/__init__.py +++ b/nameparser/__init__.py @@ -1,4 +1,4 @@ -VERSION = (1, 1, 2) +VERSION = (1, 1, 3) __version__ = '.'.join(map(str, VERSION)) __author__ = "Derek Gulbranson" __author_email__ = 'derek73@gmail.com'