Select Git revision
test_wiktor_ner.py 1.28 KiB
"""Tests for WiktorNERInputParser."""
from src.annotations import MorphosyntacticAnnotation, NerAnnotation
from src.input_parsers.wiktor_ner import WiktorNERInputParser
import clarin_json
def test_wiktor_ner_input_parser():
"""Test WiktorNERInputParser."""
parser = WiktorNERInputParser()
with clarin_json.open('example_inputs/ner_test.jsonl', 'r') as f:
for example_json in f:
text, annotations = parser.parse(example_json)
assert text == "Marek Kowalski pojechał do Wrocławia."
assert len(annotations) == 8
assert (0, 14, NerAnnotation("nam_liv_person")) in annotations
assert (27, 36, NerAnnotation("nam_loc_gpe_city")) in annotations
assert (0, 5, MorphosyntacticAnnotation("subst:sg:nom:m1", "Marek")) in annotations
assert (
6,
14,
MorphosyntacticAnnotation("subst:sg:nom:m1", "Kowalski"),
) in annotations
assert (
15,
23,
MorphosyntacticAnnotation("praet:sg:m1:perf", "pojechać"),
) in annotations
assert (24, 26, MorphosyntacticAnnotation("prep:gen", "do")) in annotations
assert (
27,
36,
MorphosyntacticAnnotation("subst:sg:gen:m3", "Wrocław"),
) in annotations
assert (36, 37, MorphosyntacticAnnotation("interp", ".")) in annotations