dedupeio / pyhacrf

:triangular_ruler: Hidden alignment conditional random field for classifying string pairs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyhacrf

image

image

Hidden alignment conditional random field for classifying string pairs -a learnable edit distance.

Part of the Dedupe.io cloud service and open source toolset for de-duplicating and finding fuzzy matches in your data: https://dedupe.io

This package aims to implement the HACRF machine learning model with a sklearn-like interface. It includes ways to fit a model to training examples and score new example.

The model takes string pairs as input and classify them into any number of classes. In McCallum's original paper the model was applied to the database deduplication problem. Each database entry was paired with every other entry and the model then classified whether the pair was a 'match' or a 'mismatch' based on training examples of matches and mismatches.

I also tried to use it as learnable string edit distance for normalizing noisy text. See A Conditional Random Field for Discriminatively-trained Finite-state String Edit Distance by McCallum, Bellare, and Pereira, and the report Conditional Random Fields for Noisy text normalisation by Dirko Coetsee.

Example

Dependencies

This package depends on numpy. The LBFGS optimizer in pylbfgs is used, but alternative optimizers can be passed.

Install

Install by running:

python setup.py install

or from pypi:

pip install pyhacrf

Developing

Clone from repository, then

pip install -r requirements.txt
cython pyhacrf/*.pyx
python setup.py install

To deploy to pypi, make sure you have compiled the *.pyx files to *.c

About

:triangular_ruler: Hidden alignment conditional random field for classifying string pairs.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 72.1%Language:Cython 27.6%Language:C 0.3%