Skip to content

Commit

Permalink
release: v0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
severinsimmler authored Jan 4, 2021
2 parents d320942 + d923839 commit 5d5ef54
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
# Chaine

A linear-chain conditional random field implementation.
Linear-chain conditional random fields for natural language processing.

Chaine is a modern Python library without any third-party dependencies and a backend written in C implementing conditional random fields for natural language processing tasks like named entity recognition or part-of-speech tagging.
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](https://en.wikipedia.org/wiki/Named-entity_recognition) or [part-of-speech tagging](https://en.wikipedia.org/wiki/Part-of-speech_tagging).

- **Lightweight:** explain
- **Fast:** explain
- **Easy to use:** explain
- **Lightweight**: No use of bloated third-party libraries.
- **Fast**: Performance critical parts are written in C and thus [blazingly fast](http://www.chokkan.org/software/crfsuite/benchmark.html).
- **Easy to use**: Designed with special focus on usability and a beautiful high-level API.

You can install the latest stable version from [PyPI](https://pypi.org/project/chaine):

```
$ pip install chaine
```

If you are interested in the theoretical concepts behind conditional random fields, refer to the introducing paper by [Lafferty et al](https://repository.upenn.edu/cgi/viewcontent.cgi?article=1162&context=cis_papers).
If you are interested in the theoretical concepts behind conditional random fields, please refer to the introducing paper by [Lafferty et al](https://repository.upenn.edu/cgi/viewcontent.cgi?article=1162&context=cis_papers).


## How it works
## Example

```
```python
>>> import chaine
>>> tokens = [["John", "Lennon", "was", "rhythm", "guitarist" "of", "The", "Beatles"]]
>>> labels = [["B-PER", "I-PER", "O", "O", "O", "O", "B-ORG", "I-ORG"]]
>>> 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)
Loading data
Start training
Iteration 1, train loss: 14.334076
Iteration 2, train loss: 14.334064
Iteration 3, train loss: 14.334053
Iteration 4, train loss: 14.334041
Iteration 5, train loss: 14.334029
>>> model.predict(tokens)
[['B-PER', 'I-PER', 'O', 'O', 'O', 'B-ORG', 'I-ORG']]
[['B-PER', 'I-PER', 'O', 'O', 'O', 'B-LOC']]
```

Check out the introducing [Jupyter notebook](https://github.com/severinsimmler/chaine/blob/master/notebooks/tutorial.ipynb).
Expand Down
2 changes: 1 addition & 1 deletion chaine/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __init__(self):
self.loss = None

def __str__(self) -> str:
return f"Iteration: {self.iteration}\tLoss: {self.loss}"
return f"Iteration {self.iteration}, train loss: {self.loss}"


class LogParser:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "chaine"
version = "0.2.1"
version = "0.2.2"
description = "A Lightweight Conditional Random Field"
authors = ["Severin Simmler <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 5d5ef54

Please sign in to comment.