Skip to main content

Payment text parser

Description

Inputs a text string and parses entity/address free text input to:

  • Flag entity fields ('ORG' for companies, 'PER' for individuals, 'PER_ORG' for uncertain decision) <= Based on Spacy
  • Flag address components of the address ('house number', 'town', 'country', ...) <= Based on Libpostal
  • Flag other fields (i.e. not entity nor address) with POS tags ('NE', 'ADJ', 'NN', ..) <= Based on CoreNLP

More generally, the package includes following features:

  • A data generator for entity/address fields and free text fields (based on open data)
  • A model distinguishing entity/address field from free text (using Keras/TensorFlow and CoreNLP) to apply dedicated heuristics
  • A series of cleaning_postprocessing steps including true case recognition (CoreNLP)
  • A parser of entity/address/other fields as described above using re-trained vanilla Spacy model (based on labeled open data)
  • Simple heuristics and metrics applied after the parsing to improve accuracy
  • Part-of-speech (POS) tagging of the remaining flags (Spacy and/or CoreNLP) for downstream processing

This package is specifically intended to be used together with the upstream Swiftflow pipeline that parses all fields from the SWIFT MT messages, including the entity/address and free text fields, which are decisive for inter-banking transactional communication.

Installation

The package uses essentally Libpostal and Spacy. Also, it uses Keras on Tensorflow to recognize if the text input is a free text or an entity/address text.

Pre-requiste: Libpostal

Refer to Libpostal installation. Once Libpostal is installed, the Python binder postal will be installed as part of the package with pip (see below)

Payment_text_parser

The other dependencies, including Spacy, will be installed via pip on the present package:

Create environment

One recommends to use Python 3.7.

Native Python:

/usr/local/bin/python3 -m venv <my_env>
source <my_env>/bin/activate`

Conda:

conda create --name <my_env> python=3.7` conda activate <my_env>

From pip
pip install payment-text-parser --use-feature=2020-resolver
python -m spacy download de_core_news_sm
From git
pip install git+https://gitlab.com/alpina-analytics/payment_text_parser.git
python -m spacy download de_core_news_sm

From requirements.txt

git clone https://gitlab.com/alpina-analytics/payment_text_parser.git
cd payment_text_parser
pip install -r requirements.txt
python -m spacy download de_core_news_sm
export PYTHONPATH=$(pwd)

Usage

Script

from payment_text_parser.entity_extractor.entity_extractor import ExtractorClass
e = ExtractorClass(text)
d_res = e.d_res

Webserver

# Launch
python main.py

# Test
curl -H "Content-type: application/json" -X POST http://127.0.0.1:5000/parse -d '{"text":"John Deere Les Abues 2 75000 Paris"}'

Optional : start Stanford NLP server

Required if :

  • Field type detection enabled by ExtractorClass(text,check_field_type=True)
  • POS-tagging of rest fields enabled by ExtractorClass(text,create_nlp_tags_rest_text=True) If not started, an warning message will be prompted, however full processing can still take place.

CoreNLP server can be started as follow:

cd ./core_nlp/stanford-corenlp-full-2018-10-05
java -Xmx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer \
-serverProperties StanfordCoreNLP-german.properties \
-preload tokenize,ssplit,pos,parse \
-status_port 9000  -port 9000 -timeout 15000

References

Spacy

https://spacy.io/

Libpostal

https://github.com/openvenues/libpostal

CoreNLP

https://stackoverflow.com/questions/33259191/installing-libicu-dev-on-mac https://stackoverflow.com/questions/50217214/import-error-for-icu-in-mac-and-ubuntu-although-pyicu-is-installed-correctly/50364835#50364835 https://www.khalidalnajjar.com/setup-use-stanford-corenlp-server-python/

Metadata

Release files for payment-text-parser 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for payment-text-parser 0.0.9
File Size Uploaded Provenance Actions
payment_text_parser-0.0.9.tar.gz 29.3 MB Without provenance Details for payment_text_parser-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for payment-text-parser 0.0.9
File Interpreter ABI Platform Actions
payment_text_parser-0.0.9-py3-none-any.whl Python 3 none any Details for payment_text_parser-0.0.9-py3-none-any.whl

Total release size: 59.1 MB

Release files / payment_text_parser-0.0.9.tar.gz

Download URL payment_text_parser-0.0.9.tar.gz
Size 29.3 MB
Tags Source
SHA-256 checksum
How to use checksums
a4fe18fe3e91d7f220f361b081820d17051b49a6564b2f570d80a8b1abb096c9
BLAKE2b-256 checksum
How to use checksums
e72a20b4ed82bf9c72dab152312b0455fcfda15ac11c653195a5cfa15b4c7b64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release files / payment_text_parser-0.0.9-py3-none-any.whl

Download URL payment_text_parser-0.0.9-py3-none-any.whl
Size 29.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a394085a157070f71259e48e03a57dd6ac275b739d54aac14007a0b67667c087
BLAKE2b-256 checksum
How to use checksums
ed6a23c67d2f0629e34d9aa550c63e368fa0907e87724ebd89eefe8493577734
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Security for payment-text-parser 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page