Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon committed Jul 4, 2022
1 parent a2889e4 commit 8d202be
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/server/token_classification/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,37 @@ def test_annotated_without_entities():
assert record.annotated_by == [record.annotation.agent]
assert record.predicted_by == [record.prediction.agent]
assert record.predicted == PredictionStatus.KO


def test_adjust_spans():

text = "A text with some empty spaces that could bring not cleany annotated spans"

record = TokenClassificationRecord(
text=text,
tokens=text.split(),
prediction=TokenClassificationAnnotation(
agent="pred.test",
entities=[
EntitySpan(start=-3, end=2, label="DET"),
EntitySpan(start=24, end=36, label="NAME"),
],
),
annotation=TokenClassificationAnnotation(
agent="test",
entities=[
EntitySpan(start=48, end=61, label="VERB"),
EntitySpan(start=68, end=100, label="DET"),
],
),
)

assert record.prediction.entities == [
EntitySpan(start=0, end=1, label="DET"),
EntitySpan(start=28, end=34, label="NAME"),
]

assert record.annotation.entities == [
EntitySpan(start=50, end=60, label="VERB"),
EntitySpan(start=70, end=85, label="DET"),
]

0 comments on commit 8d202be

Please sign in to comment.