Пример #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
Пример #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
Пример #3
0
def strict_generator():
    return TransducerFile(FST_DIR / settings.STRICT_GENERATOR_FST_FILENAME)
Пример #4
0
def strict_analyzer():
    return TransducerFile(FST_DIR / settings.STRICT_ANALYZER_FST_FILENAME)
Пример #5
0
def relaxed_analyzer():
    return TransducerFile(FST_DIR / settings.RELAXED_ANALYZER_FST_FILENAME)
Пример #6
0
def test_create_from_path_obj() -> None:
    fst = TransducerFile(Path(TEST_FST))
    assert fst.lookup("itwêwina") == ["itwêwin+N+I+Pl"]
Пример #7
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
Пример #8
0
def fst() -> TransducerFile:
    return TransducerFile(TEST_FST)
Пример #9
0
def strict_generator_with_morpheme_boundaries():
    return TransducerFile(
        FST_DIR / "crk-strict-generator-with-morpheme-boundaries.hfstol"
    )
Пример #10
0
def cmro_transcriptor():
    return TransducerFile(settings.BASE_DIR / "resources" / "fst" /
                          "default-to-cmro.hfstol")