Skip to content
Snippets Groups Projects
Select Git revision
  • 923c30f0d6c9e6c0de692b9641b8eb3c2d957d6e
  • master default protected
  • develop protected
  • develop-0.7.x
  • develop-0.8.0
  • dev_czuk
  • loader
  • kgr10_roberta
  • 14-BiLSTM-CRF-RoBERTa
  • 12-handle-long-sequences
  • 13-flair-embeddings
  • BiLSTM
  • v0.7.0
  • v0.6.1
  • v0.5
  • v0.4.1
  • v0.3
17 results

train-batch.py

Blame
  • 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