class ManuscriptLineFactory(factory.Factory):
    class Meta:
        model = ManuscriptLine

    manuscript_id = factory.Sequence(lambda n: n)
    labels = (
        SurfaceLabel.from_label(Surface.OBVERSE),
        ColumnLabel.from_label("iii", [Status.COLLATION, Status.CORRECTION]),
    )
    line = factory.Sequence(
        lambda n: TextLine.of_iterable(
            LineNumber(n),
            (
                Word.of(
                    [
                        Reading.of_name("ku"),
                        Joiner.hyphen(),
                        BrokenAway.open(),
                        Reading.of_name("nu"),
                        Joiner.hyphen(),
                        Reading.of_name("ši"),
                        BrokenAway.close(),
                    ]
                ),
            ),
        )
    )
    paratext = (NoteLine((StringPart("note"),)), RulingDollarLine(Ruling.SINGLE))
    omitted_words = (1,)
class LabelsFactory(factory.Factory):
    class Meta:
        model = Labels

    object = None
    surface = factory.fuzzy.FuzzyChoice(
        [None, SurfaceLabel.from_label(Surface.OBVERSE)]
    )
    column = None
Ejemplo n.º 3
0
 def ebl_atf_text_line__edge(self, text: str = ""):
     return SurfaceLabel.from_label(atf.Surface.EDGE, text=text)
Ejemplo n.º 4
0
 def ebl_atf_text_line__face(self, text: Token):
     return SurfaceLabel.from_label(atf.Surface.FACE, text=str(text))
Ejemplo n.º 5
0
 def ebl_atf_text_line__generic_surface(self, text: str):
     return SurfaceLabel.from_label(atf.Surface.SURFACE, text=text)
Ejemplo n.º 6
0
 def ebl_atf_text_line__SURFACE(self, surface: Token):
     return SurfaceLabel.from_label(
         atf.Surface.from_atf(surface))  # pyre-ignore[6]
def test_parse_labels_multiple() -> None:
    labels = (SurfaceLabel.from_label(Surface.OBVERSE),
              ColumnLabel.from_int(3))
    assert parse_labels(" ".join(label.to_value()
                                 for label in labels)) == labels
Ejemplo n.º 8
0
from ebl.corpus.domain.chapter import Chapter
from ebl.corpus.domain.line import Line, LineVariant, ManuscriptLine
from ebl.corpus.domain.manuscript import Manuscript
from ebl.transliteration.domain.text_id import TextId
from ebl.transliteration.domain.line_number import LineNumber
from ebl.transliteration.domain.sign_tokens import Reading
from ebl.transliteration.domain.text_line import TextLine
from ebl.transliteration.domain.tokens import ValueToken
from ebl.transliteration.domain.word_tokens import Word
from ebl.transliteration.domain.genre import Genre
from ebl.transliteration.domain.labels import SurfaceLabel
from ebl.transliteration.domain.atf import Surface
from ebl.corpus.web.extant_lines import ExtantLinesSchema
from ebl.transliteration.application.line_number_schemas import OneOfLineNumberSchema

LABELS = (SurfaceLabel.from_label(Surface.OBVERSE), )
MANUSCRIPT_TEXT_1 = TextLine(LineNumber(2),
                             (Word.of([Reading.of([ValueToken.of("ku")])]), ))


def test_extant_lines_schema() -> None:
    manuscript = Manuscript(1)
    manuscript_line = ManuscriptLine(1, LABELS, MANUSCRIPT_TEXT_1)
    variant = LineVariant(tuple(), manuscripts=(manuscript_line, ))
    text_line = Line(LineNumber(1), (variant, ))
    chapter = Chapter(TextId(Genre.LITERATURE, 0, 0),
                      manuscripts=(manuscript, ),
                      lines=(text_line, ))
    assert ExtantLinesSchema().dump(chapter) == {
        "extantLines": {
            str(manuscript.siglum): {
Ejemplo n.º 9
0
)


@pytest.mark.parametrize(
    "line,expected_line",
    [
        (
            "// cf. F K.1 &d tablet* o! iii? 1",
            ParallelFragment(
                True,
                MuseumNumber.of("K.1"),
                True,
                Labels(
                    ObjectLabel.from_object(atf.Object.TABLET,
                                            [atf.Status.COLLATION]),
                    SurfaceLabel.from_label(atf.Surface.OBVERSE,
                                            [atf.Status.CORRECTION]),
                    ColumnLabel.from_int(3, [atf.Status.UNCERTAIN]),
                ),
                LineNumber(1),
            ),
        ),
        (
            "// F K.1 1",
            ParallelFragment(False, MuseumNumber.of("K.1"), False, Labels(),
                             LineNumber(1)),
        ),
        (
            '// cf. L I.1 OB "my name" 1',
            ParallelText(
                True,
                TextId(Genre.LITERATURE, 1, 1),
Ejemplo n.º 10
0
MANUSCRIPT_ID = 1
LABELS = (ColumnLabel.from_int(1), )
TEXT_LINE = TextLine(
    LineNumber(1),
    (
        Word.of([Reading.of_name("kur")],
                unique_lemma=(WordId("word1"), ),
                alignment=0),
        Word.of([Reading.of_name("ra")],
                unique_lemma=(WordId("word2"), ),
                alignment=None),
    ),
)

NEW_MANUSCRIPT_ID = 2
NEW_LABELS = (SurfaceLabel.from_label(Surface.REVERSE), )
NEW_TEXT_LINE = TextLine(
    LineNumber(1),
    (Word.of([Reading.of_name("kur")]), Word.of([Reading.of_name("pa")])))
MANUSCRIPT_LINE = ManuscriptLine(MANUSCRIPT_ID, LABELS, TEXT_LINE)


@pytest.mark.parametrize(
    "old,new,expected",
    [
        (MANUSCRIPT_LINE, MANUSCRIPT_LINE, MANUSCRIPT_LINE),
        (
            MANUSCRIPT_LINE,
            ManuscriptLine(NEW_MANUSCRIPT_ID, NEW_LABELS, NEW_TEXT_LINE),
            ManuscriptLine(NEW_MANUSCRIPT_ID, NEW_LABELS,
                           TEXT_LINE.merge(NEW_TEXT_LINE)),