def _transform_erasure(self, erased, over_erased): return [ Erasure.open(), *set_erasure_state(erased, ErasureState.ERASED), Erasure.center(), *set_erasure_state(over_erased, ErasureState.OVER_ERASED), Erasure.close(), ]
import pytest from ebl.transliteration.domain.enclosure_tokens import Erasure from ebl.transliteration.domain.lark_parser import parse_erasure from ebl.transliteration.domain.sign_tokens import Divider, Reading from ebl.transliteration.domain.unknown_sign_tokens import UnclearSign, UnidentifiedSign from ebl.transliteration.domain.word_tokens import ErasureState, Word ERASURE_LEFT = Erasure.open() ERASURE_CENTER = Erasure.center() ERASURE_RIGHT = Erasure.close() @pytest.mark.parametrize("parser", [parse_erasure]) @pytest.mark.parametrize( "atf,erased,over_erased", [ ( "°ku\\ku°", (Word.of(erasure=ErasureState.ERASED, parts=[Reading.of_name("ku")]), ), (Word.of(erasure=ErasureState.OVER_ERASED, parts=[Reading.of_name("ku")]), ), ), ( "°::\\:.°", (Divider.of("::").set_erasure(ErasureState.ERASED), ), (Divider.of(":.").set_erasure(ErasureState.OVER_ERASED), ), ), ( "°\\ku°",
TextLine.of_iterable( LineNumber(1), ( Variant.of(Reading.of_name("sal"), Divider.of(":")), Word.of([Reading.of_name("šim")]), ), ) ], ), ( "1. °me-e-li\\ku°", [ TextLine.of_iterable( LineNumber(1), ( Erasure.open(), Word.of( erasure=ErasureState.ERASED, parts=[ Reading.of_name("me"), Joiner.hyphen(), Reading.of_name("e"), Joiner.hyphen(), Reading.of_name("li"), ], ), Erasure.center(), Word.of( erasure=ErasureState.OVER_ERASED, parts=[Reading.of_name("ku")], ),
def make_token(self, data, **kwargs): return ( Erasure.of(data["side"]) .set_enclosure_type(frozenset(data["enclosure_type"])) .set_erasure(data["erasure"]) )
line = TextLine.of_iterable( LINE_NUMBER, [ DocumentOrientedGloss.open(), Word.of([Reading.of_name("mu")]), Word.of([Reading.of_name("bu")]), DocumentOrientedGloss.close(), ], ) assert line.atf == f"{line.line_number.atf} {{(mu bu)}}" @pytest.mark.parametrize( # pyre-ignore[56] "erasure,expected", [ ([Erasure.open(), Erasure.center(), Erasure.close()], "°\\°"), ( [ Erasure.open(), Word.of([ Reading.of_name("mu"), Joiner.hyphen(), Reading.of_name("bu") ]), Erasure.center(), Erasure.close(), ], "°mu-bu\\°", ), (