Skip to main content

A Lightweight Conditional Random Field

Project description

Chaine

Linear-chain conditional random fields for natural language processing.

Chaine is a modern Python library without third-party dependencies and a backend written in C. You can train conditional random fields for natural language processing tasks like named entity recognition or part-of-speech tagging.

  • Lightweight: No use of bloated third-party libraries.
  • Fast: Performance critical parts are written in C and thus blazingly fast.
  • Easy to use: Designed with special focus on usability and a beautiful high-level API.

You can install the latest stable version from PyPI:

$ pip install chaine

If you are interested in the theoretical concepts behind conditional random fields, please refer to the introducing paper by Lafferty et al.

Example

>>> import chaine
>>> tokens = [["John", "Lennon", "was", "born", "in" "Liverpool"]]
>>> labels = [["B-PER", "I-PER", "O", "O", "O", "B-LOC"]]
>>> model = chaine.train(tokens, labels, max_iterations=5)
>>> model.predict(tokens)
[['B-PER', 'I-PER', 'O', 'O', 'O', 'B-LOC']]

Check out the introducing Jupyter notebook.

Credits

This library makes use of and is partially based on:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chaine-0.2.2.tar.gz (116.5 kB view hashes)

Uploaded Source

Built Distributions

chaine-0.2.2-cp39-cp39-manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.9

chaine-0.2.2-cp38-cp38-manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.8

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page