pyprocessors-nameparser 0.5.3__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.
- pyprocessors_nameparser/__init__.py +2 -0
- pyprocessors_nameparser/name_parser.py +40 -0
- pyprocessors_nameparser-0.5.3.dist-info/METADATA +66 -0
- pyprocessors_nameparser-0.5.3.dist-info/RECORD +6 -0
- pyprocessors_nameparser-0.5.3.dist-info/WHEEL +4 -0
- pyprocessors_nameparser-0.5.3.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from logging import Logger
|
|
2
|
+
from typing import List, Type, cast
|
|
3
|
+
from log_with_context import add_logging_context
|
|
4
|
+
from nameparser import HumanName
|
|
5
|
+
from pydantic import Field, BaseModel
|
|
6
|
+
from pymultirole_plugins.v1.processor import ProcessorParameters, ProcessorBase
|
|
7
|
+
from pymultirole_plugins.v1.schema import Document
|
|
8
|
+
|
|
9
|
+
logger = Logger("pymultirole")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class NameParserParameters(ProcessorParameters):
|
|
13
|
+
name_labels: List[str] = Field(None, description="List of labels to analyze", extra="label")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class NameParserProcessor(ProcessorBase):
|
|
17
|
+
__doc__ = """NameParser based on [Nameparser](https://github.com/derek73/python-nameparser)."""
|
|
18
|
+
|
|
19
|
+
def process(
|
|
20
|
+
self, documents: List[Document], parameters: ProcessorParameters
|
|
21
|
+
) -> List[Document]:
|
|
22
|
+
params: NameParserParameters = cast(NameParserParameters, parameters)
|
|
23
|
+
try:
|
|
24
|
+
for document in documents:
|
|
25
|
+
with add_logging_context(docid=document.identifier):
|
|
26
|
+
if document.annotations:
|
|
27
|
+
for a in document.annotations:
|
|
28
|
+
if a.labelName in params.name_labels:
|
|
29
|
+
atext = a.text or document.text[a.start:a.end]
|
|
30
|
+
name = HumanName(atext)
|
|
31
|
+
props = a.properties or {}
|
|
32
|
+
props.update(name.as_dict())
|
|
33
|
+
a.properties = props
|
|
34
|
+
except BaseException as err:
|
|
35
|
+
raise err
|
|
36
|
+
return documents
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
def get_model(cls) -> Type[BaseModel]:
|
|
40
|
+
return NameParserParameters
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: pyprocessors-nameparser
|
|
3
|
+
Version: 0.5.3
|
|
4
|
+
Summary: Processor based on Nameparser
|
|
5
|
+
Home-page: https://kairntech.com/
|
|
6
|
+
Author: Olivier Terrier
|
|
7
|
+
Author-email: olivier.terrier@kairntech.com
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Classifier: Intended Audience :: Information Technology
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: System Administrators
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Classifier: Topic :: Software Development
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Development Status :: 4 - Beta
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Requires-Dist: pymultirole_plugins>=0.5.0,<0.6.0
|
|
22
|
+
Requires-Dist: log-with-context
|
|
23
|
+
Requires-Dist: nameparser
|
|
24
|
+
Requires-Dist: flit ; extra == "dev"
|
|
25
|
+
Requires-Dist: pre-commit ; extra == "dev"
|
|
26
|
+
Requires-Dist: bump2version ; extra == "dev"
|
|
27
|
+
Requires-Dist: sphinx ; extra == "docs"
|
|
28
|
+
Requires-Dist: sphinx-rtd-theme ; extra == "docs"
|
|
29
|
+
Requires-Dist: m2r2 ; extra == "docs"
|
|
30
|
+
Requires-Dist: sphinxcontrib.apidoc ; extra == "docs"
|
|
31
|
+
Requires-Dist: jupyter_sphinx ; extra == "docs"
|
|
32
|
+
Requires-Dist: pytest ; extra == "test"
|
|
33
|
+
Requires-Dist: pytest-cov ; extra == "test"
|
|
34
|
+
Requires-Dist: pytest-flake8 ; extra == "test"
|
|
35
|
+
Requires-Dist: pytest-black ; extra == "test"
|
|
36
|
+
Requires-Dist: flake8==3.9.2 ; extra == "test"
|
|
37
|
+
Requires-Dist: tox ; extra == "test"
|
|
38
|
+
Requires-Dist: dirty-equals ; extra == "test"
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Provides-Extra: docs
|
|
41
|
+
Provides-Extra: test
|
|
42
|
+
|
|
43
|
+
## Requirements
|
|
44
|
+
|
|
45
|
+
- Python 3.8+
|
|
46
|
+
- Flit to put Python packages and modules on PyPI
|
|
47
|
+
- Pydantic for the data parts.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
```
|
|
51
|
+
pip install flit
|
|
52
|
+
pip install pymultirole-plugins
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Publish the Python Package to PyPI
|
|
56
|
+
- Increment the version of your package in the `__init__.py` file:
|
|
57
|
+
```
|
|
58
|
+
"""An amazing package!"""
|
|
59
|
+
|
|
60
|
+
__version__ = 'x.y.z'
|
|
61
|
+
```
|
|
62
|
+
- Publish
|
|
63
|
+
```
|
|
64
|
+
flit publish
|
|
65
|
+
```
|
|
66
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pyprocessors_nameparser/__init__.py,sha256=a4WFNpgXNuycl7nBl6htcwuqNVtzZZqOr4W4v9l6iYg,58
|
|
2
|
+
pyprocessors_nameparser/name_parser.py,sha256=IlnzhIh-KZ_boioIbD7Twmk_BKcfbZ7C-hiwWmvHOnE,1612
|
|
3
|
+
pyprocessors_nameparser-0.5.3.dist-info/entry_points.txt,sha256=oSXv5f-MM5qa9WCWGOUwu5gfbIpxltpcg83MNRyCNHk,91
|
|
4
|
+
pyprocessors_nameparser-0.5.3.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
|
5
|
+
pyprocessors_nameparser-0.5.3.dist-info/METADATA,sha256=at6ePgWBormrbWceCtiynJHydCDPXXermnjj5RIx-7g,2081
|
|
6
|
+
pyprocessors_nameparser-0.5.3.dist-info/RECORD,,
|