Library for normalizing entities based on a dictionary
Project description
Entity Normalizer
Python tool for normalizing entities based on a dictionary.
Usage
This tool can be used as:
- a command line tool, by cloning this repository and running
pip install .
under the root of this source; then you can runmain.py
with the required parameters to process your entity-listed file. - a Python package , by installing the package using
pip install EntityNormalizer
Input and output
The input file must contain one entity per line.
The output file will contain the normalized entities, again, one per line.
The dicitory file must be a comma-separated table file, i.e., csv
.
If the entity does not produce any match in the dictionary, it will be normalized to [NO_MATCH]
.
If the entity is found in the dictionary but the normalization is empty, it will be normalized to [NO_NORM_FOUND]
.
Command line usage
python main.py input output dictionary source target [--matching_threshold MATCHING_THRESHOLD] [--index]
Parameters
input
: Input file path [Required]output
: Output file path [Required]dictionary
: Normalization dictionary file path [Required]source
: Surface form column from dictionary [Required]target
: Normalization column from dictionary [Required]matching_threshold
: Threshold of string similarity for the normalization to be accepted (default: 50) [Optional]index
: Use column indexes instead of names [Optional]
Example
- With column names:
python main.py data/input.txt data/output.txt data/dictionary.csv surface_form_col normalization_col --matching_threshold 50
- With integer column indexes:
python main.py data/input.txt data/output.txt data/dictionary.csv --index source 0 target 2 --matching_threshold 80
Python package usage
After instalation, the normalized
function can be invoked with the dicitonary and a list
of entities to produce a list
of normalized entities.
Example
from EntityNormalizer import EntityDictionary, normalize
entities = [entity1, entity2, entity3]
normalization_dictionary = EntityDictionary('data/dictionary.csv', 'surface_forms', 'normalizations')
normalized = normalize(entities, normalization_dictionary, matching_threshold=70)
print(normalized)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for EntityNormalizer-0.1.0.post2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0d26cbf5a33939e95d0753b7a4d8caaeb23ebba1889ebfebb5d7f66250ad378 |
|
MD5 | 6cc3e2e1c6f581f7d51c5c897007088a |
|
BLAKE2b-256 | 6ec00ac42845e86f42b775efe5a0f37db40f1554e1152baaa567ccf179d62247 |
Hashes for EntityNormalizer-0.1.0.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cda365a7f4e767ab7c569b989326f2c441902f7e3878343329f4dac2989f3395 |
|
MD5 | 6cfdcecd286653064d8c8ce03aec1e87 |
|
BLAKE2b-256 | e8743b3fad461b28e6d1f794775ca422224474b9f005260ec0837b8003f9c2ea |