Skip to content

Commit

Permalink
Merge pull request #47 from severinsimmler/dev
Browse files Browse the repository at this point in the history
v1.3.1
  • Loading branch information
realjanpaulus authored Jul 7, 2021
2 parents 7d0739f + b21edb9 commit a808ea3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions chaine/crf.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ cdef class Model:
List[Dict[str, float]]
Probability distributions over all labels for each token
"""
if not isinstance(sequence, list):
sequence = list(sequence)
self._set_sequence(sequence)
return [
{label: self._marginal(label, index) for label in self.labels}
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 = "1.3.0"
version = "1.3.1"
description = "Linear-chain conditional random fields for natural language processing"
authors = ["Severin Simmler <[email protected]>"]
readme = "README.md"
Expand Down
9 changes: 9 additions & 0 deletions tests/test_crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ def test_model_predict(model, dataset):
assert predicted == expected


def test_model_predict_generator(model, dataset):
generator = (
(features for features in sequence) for sequence in dataset["sequences"]
)
predicted = model.predict(generator)
expected = dataset["labels"]
assert predicted == expected


def test_model_predict_proba_single(model, dataset):
for sequence in dataset["sequences"]:
predicted = model.predict_proba_single(sequence)
Expand Down

0 comments on commit a808ea3

Please sign in to comment.