class LineVariantFactory(factory.Factory): class Meta: model = LineVariant class Params: manuscript_id = factory.Sequence(lambda n: n) manuscript = factory.SubFactory( ManuscriptLineFactory, manuscript_id=factory.SelfAttribute("..manuscript_id"), ) reconstruction = ( LanguageShift.normalized_akkadian(), AkkadianWord.of((ValueToken.of("buāru"),)), MetricalFootSeparator.uncertain(), BrokenAway.open(), UnknownNumberOfSigns.of(), Caesura.certain(), AkkadianWord.of( ( UnknownNumberOfSigns.of(), BrokenAway.close(), Joiner.hyphen(), ValueToken.of("buāru"), ), (Flag.DAMAGE,), ), ) note = factory.fuzzy.FuzzyChoice([None, NoteLine((StringPart("a note"),))]) manuscripts = factory.List([factory.SelfAttribute("..manuscript")], TupleFactory) intertext = factory.fuzzy.FuzzyChoice([tuple(), (StringPart("bar"),)]) parallel_lines = factory.List( [ factory.SubFactory(ParallelCompositionFactory), factory.SubFactory(ParallelTextFactory), factory.SubFactory(ParallelFragmentFactory), ], TupleFactory, )
word = AkkadianWord.of((ValueToken.of("bu"), )) expected = AkkadianWord.of((ValueToken.of("bu"), ), alignment=1) assert word.set_alignment(1, None) == expected def test_set_alignment_empty() -> None: word = AkkadianWord.of((ValueToken.of("bu"), ), alignment=1) expected = AkkadianWord.of((ValueToken.of("bu"), )) assert word.set_alignment(None, None) == expected @pytest.mark.parametrize( # pyre-ignore[56] "caesura,is_uncertain,value", [(Caesura.certain(), False, "||"), (Caesura.uncertain(), True, "(||)")], ) def test_caesura(caesura: Caesura, is_uncertain: bool, value: str) -> None: assert caesura.value == value assert caesura.is_uncertain == is_uncertain serialized = {"type": "Caesura", "isUncertain": is_uncertain} assert_token_serialization(caesura, serialized) @pytest.mark.parametrize( # pyre-ignore[56] "separator,is_uncertain,value", [ (MetricalFootSeparator.certain(), False, "|"), (MetricalFootSeparator.uncertain(), True, "(|)"), ],
def test_create_alignment_map_remove_unalignable() -> None: assert create_alignment_map(_make_sequence(["kur"]), [Caesura.certain()]) == [None]
def ebl_atf_text_line__uncertain_caesura(self, _) -> Caesura: return Caesura.uncertain()
def make_token(self, data, **kwargs): return Caesura.of(data["is_uncertain"]).set_enclosure_type( frozenset(data["enclosure_type"]) )
Emendation.open(), UnknownNumberOfSigns(frozenset({EnclosureType.EMENDATION}), ErasureState.NONE), MetricalFootSeparator.certain().set_enclosure_type( frozenset({EnclosureType.EMENDATION})), UnknownNumberOfSigns(frozenset({EnclosureType.EMENDATION}), ErasureState.NONE), Emendation.close().set_enclosure_type( frozenset({EnclosureType.EMENDATION})), ), ), ( "%n <... || ...>", ( LanguageShift.normalized_akkadian(), Emendation.open(), UnknownNumberOfSigns(frozenset({EnclosureType.EMENDATION}), ErasureState.NONE), Caesura.certain().set_enclosure_type( frozenset({EnclosureType.EMENDATION})), UnknownNumberOfSigns(frozenset({EnclosureType.EMENDATION}), ErasureState.NONE), Emendation.close().set_enclosure_type( frozenset({EnclosureType.EMENDATION})), ), ), ], ) def test_enclosure_type(atf, expected): assert map_line(atf) == expected
def test_caesura(text, is_uncertain) -> None: assert ( parse_break(text) == Caesura.uncertain() if is_uncertain else Caesura.certain() )
), ( "ib...nû", ( AkkadianWord.of( ( ValueToken.of("ib"), UnknownNumberOfSigns.of(), ValueToken.of("nû"), ) ), ), ), ("ibnû | ibnû", (WORD, MetricalFootSeparator.certain(), WORD)), ("ibnû (|) ibnû", (WORD, MetricalFootSeparator.uncertain(), WORD)), ("ibnû || ibnû", (WORD, Caesura.certain(), WORD)), ("ibnû (||) ibnû", (WORD, Caesura.uncertain(), WORD)), ("...", (UnknownNumberOfSigns.of(),)), ("[...", (BrokenAway.open(), UnknownNumberOfSigns.of())), ("...]", (UnknownNumberOfSigns.of(), BrokenAway.close())), ("[...]", (BrokenAway.open(), UnknownNumberOfSigns.of(), BrokenAway.close())), ("(...", (PerhapsBrokenAway.open(), UnknownNumberOfSigns.of())), ("...)", (UnknownNumberOfSigns.of(), PerhapsBrokenAway.close())), ( "(...)", ( PerhapsBrokenAway.open(), UnknownNumberOfSigns.of(), PerhapsBrokenAway.close(), ), ),
(LineVariant( RECONSTRUCTION_WITHOUT_LEMMA, None, (MANUSCRIPT_LINE.update_alignments([]), ), ), ), ), Line(LineNumber(1), (LineVariant(RECONSTRUCTION, None, (MANUSCRIPT_LINE, )), )), ), ( Line(LineNumber(1), (LineVariant(RECONSTRUCTION, None, (MANUSCRIPT_LINE, )), )), Line( LineNumber(1), (LineVariant( (Caesura.certain(), ), None, (MANUSCRIPT_LINE.update_alignments([]), ), ), ), ), Line( LineNumber(1), (LineVariant( (Caesura.certain(), ), None, (MANUSCRIPT_LINE.update_alignments([None]), ), ), ), ), ), ], )