Esempio n. 1
0
def test_raises_exception_on_invalid_file() -> None:
    with pytest.raises(Exception) as exception_info:
        # The python test file is not a valid transducer.
        TransducerFile(__file__)

    exception_messages = " ".join(exception_info.value.args)
    assert "wrong or corrupt file?" in exception_messages
Esempio n. 2
0
def test_raises_exception_on_missing_file() -> None:
    with pytest.raises(Exception) as exception_info:
        TransducerFile("/does-not-exist.hfstol")

    exception_messages = " ".join(exception_info.value.args)
    assert "Transducer not found" in exception_messages
    assert "‘/does-not-exist.hfstol’" in exception_messages
Esempio n. 3
0
def relaxed_analyzer():
    return TransducerFile(FST_DIR / settings.RELAXED_ANALYZER_FST_FILENAME)
Esempio n. 4
0
def test_symbol_lookup1(fst: TransducerFile, surface: str,
                        deep: list[list[str]]) -> None:
    assert fst.lookup_symbols(surface) == deep
Esempio n. 5
0
def test_limit(fst: TransducerFile) -> None:
    assert fst.lookup("môswa", limit=1) == ["môswa+N+A+Sg"]  # type: ignore
Esempio n. 6
0
def test_create_from_path_obj() -> None:
    fst = TransducerFile(Path(TEST_FST))
    assert fst.lookup("itwêwina") == ["itwêwin+N+I+Pl"]
Esempio n. 7
0
def test_bulk_lookup_with_iterator(fst: TransducerFile) -> None:
    assert (fst.bulk_lookup(w for w in EXPECTED_BULK_LOOKUP_RESULT_1.keys()) ==
            EXPECTED_BULK_LOOKUP_RESULT_1)
Esempio n. 8
0
def test_bulk_lookup(fst: TransducerFile) -> None:
    assert (fst.bulk_lookup(
        EXPECTED_BULK_LOOKUP_RESULT_1.keys()) == EXPECTED_BULK_LOOKUP_RESULT_1)
Esempio n. 9
0
def strict_generator_with_morpheme_boundaries():
    return TransducerFile(
        FST_DIR / "crk-strict-generator-with-morpheme-boundaries.hfstol"
    )
Esempio n. 10
0
def test_valid_lookup_with_invalid_symbol(fst: TransducerFile) -> None:
    assert fst.lookup("avocado") == []
    assert fst.lookup("navajo") == []
Esempio n. 11
0
def test_subsequent_lookups(fst: TransducerFile) -> None:
    assert fst.lookup("itwêwina") == ["itwêwin+N+I+Pl"]
    assert fst.lookup("nikî-nipân") == ["PV/ki+nipâw+V+AI+Ind+1Sg"]
Esempio n. 12
0
def test_symbol_count() -> None:
    # If this returned a non-number, we’d get a TypeError here.
    assert TransducerFile(TEST_FST).symbol_count() > 0
Esempio n. 13
0
def test_lookup_lemma_with_affixes(fst: TransducerFile, surface: str,
                                   example: Analysis) -> None:
    analyses = fst.lookup_lemma_with_affixes(surface)
    assert example in analyses
Esempio n. 14
0
def fst() -> TransducerFile:
    return TransducerFile(TEST_FST)
Esempio n. 15
0
def strict_analyzer():
    return TransducerFile(FST_DIR / settings.STRICT_ANALYZER_FST_FILENAME)
Esempio n. 16
0
def test_multiple_analyses(fst: TransducerFile) -> None:
    assert fst.lookup("môswa") == ["môswa+N+A+Sg", "môswa+N+A+Obv"]
Esempio n. 17
0
def strict_generator():
    return TransducerFile(FST_DIR / settings.STRICT_GENERATOR_FST_FILENAME)
Esempio n. 18
0
def cmro_transcriptor():
    return TransducerFile(settings.BASE_DIR / "resources" / "fst" /
                          "default-to-cmro.hfstol")