Linear-chain conditional random fields for natural language processing
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.
- 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
Please refer to the introducing paper by Lafferty et al. for the theoretical concepts behind conditional random fields.
Minimal working 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 examples for a more real-world use case.
Development
If you have modified chaine/crf.pyx
, you have to compile Cython to C++ first (which will update chainie/crf.cpp
) and then build the extension:
$ python cythonize && poetry install
Credits
This project makes use of and is partially based on:
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 Distributions
Built Distributions
Hashes for chaine-1.4.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74f19ec6dfa4b3f9fd142caae4a356857a5c188c164587d25414efc2ce1f37be |
|
MD5 | 4281595b00a461f00d58244296b1df57 |
|
BLAKE2b-256 | 06842122183238eb21fb71b7b7a4067d212fadd2dffb0923b044ce7812cade9b |
Hashes for chaine-1.4.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 966a92ff2ece5116466f8405c4416cc9d3037f85b31a778d42d3227f3e8a6a28 |
|
MD5 | 288f57098e9eb83eb1f6aa594185e200 |
|
BLAKE2b-256 | b8bc8bdb2ca16bbf592a34bcf91bdc8e8ad2e9d1268c89293cf0d8733aba4981 |
Hashes for chaine-1.4.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59ddf41f89776a65b4656ffc48fbe29b9d5e6e09c6af47ea75ca3a2304176787 |
|
MD5 | 33ad600e8bdc6241fccc8fc82806f0d3 |
|
BLAKE2b-256 | 315223273a91b09a41412d76cfb329645c37b1c1f056bb1a93fa13f28eccb61e |
Hashes for chaine-1.4.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68503bedb584f413dbd3c36171cdbb7cef328ba179e2ce7750b4d2e34671e4fd |
|
MD5 | 73785087b87c0027f511bbfe59ada1f8 |
|
BLAKE2b-256 | af66ebc8c965683aeaa72cfacd582a4ab2c00cf1e38d39fe13f5838888db403c |
Hashes for chaine-1.4.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 397d24c47cc0dba61c51ecfdea1db6146cc2f3e579d6b3602b133316ca16c6b8 |
|
MD5 | cf5bb23c3940bd4c862d4495d597146b |
|
BLAKE2b-256 | 2c531881c84ff1e52bd0b53cc32dd0be5e335fd070ab68c2d4bc5a8cc6c7943b |
Hashes for chaine-1.4.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f746e58d58a8d1e4b431c4ac799fac7e683c1bafcaff3806fd1a4955e6a24bee |
|
MD5 | 36ab00c46700ef9c91fda50d812fca7c |
|
BLAKE2b-256 | b9ac9ba27c8eb08de4702415cc9b52914cb31a0bcbbda9612cd92cd40143e1da |
Hashes for chaine-1.4.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2958737d48043fd3ae83f7f362959b7d10b490e7cff14d4b8ebeb842c23de839 |
|
MD5 | af579b25b5851be0dbdfb57698bcfaa1 |
|
BLAKE2b-256 | 584aed81a5c831fd89969b200dfe31db067477874ee515b1decf6e9d534c453c |
Hashes for chaine-1.4.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 050090831f7c8efeb27e984f78ab230693b84507c0066730f60e52a0b726a3a7 |
|
MD5 | f024b2448567f1c438ff08020db422d0 |
|
BLAKE2b-256 | ed9eb19bedbfebba58b74cbe7512f68bcdcbb5a7989f75e906b61d9a7199cb7b |
Hashes for chaine-1.4.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ac570c6a4e1e4ed2ca9551768ce8254e5eb4ad7bdf967e15375395445cd8e65 |
|
MD5 | aafd55acbd09af393de4af5f0339a77c |
|
BLAKE2b-256 | 9c217e5616730b46058a4e04cefedcbf611e3b0d276341cc0f402e2e1bf354ba |
Hashes for chaine-1.4.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b38953c059f42f21dc6ad3d74ff34e429b86899a4d786dd161ac9877b2b49ca9 |
|
MD5 | 10fc54d0fb6973912398de88f521a847 |
|
BLAKE2b-256 | 972c4c42ec59f4c3433e31b3dbe1428fad8ca83d570b77304807e335c70ae4ee |