class RulingDollarLineSchema(DollarLineSchema):
    number = NameEnum(atf.Ruling, required=True)
    status = NameEnum(atf.DollarStatus, load_default=None)
    display_value = fields.String(data_key="displayValue")

    @post_load
    def make_line(self, data, **kwargs) -> RulingDollarLine:
        return RulingDollarLine(data["number"], data["status"])
Esempio n. 2
0
class ObjectAtLineSchema(AtLineSchema):
    status = fields.List(NameEnum(atf.Status), load_only=True)
    object_label = NameEnum(atf.Object, load_only=True)
    text = fields.String(dump_default="", load_only=True)
    label = fields.Nested(ObjectLabelSchema)
    display_value = fields.String(data_key="displayValue")

    @post_load
    def make_line(self, data, **kwargs) -> ObjectAtLine:
        return ObjectAtLine(data["label"])
Esempio n. 3
0
class BaseTokenSchema(Schema):
    class Meta:
        unknown = EXCLUDE

    value = fields.String(required=True)
    clean_value = fields.String(data_key="cleanValue")
    enclosure_type = fields.List(
        NameEnum(EnclosureType), load_default=list, data_key="enclosureType"
    )
    erasure = NameEnum(ErasureState, load_default=ErasureState.NONE)
Esempio n. 4
0
class ObjectLabelSchema(LabelSchema):
    object = NameEnum(atf.Object, required=True)
    text = fields.String(dump_default="")

    @post_load
    def make_label(self, data, **kwargs) -> ObjectLabel:
        return ObjectLabel(data["status"], data["object"], data["text"])
Esempio n. 5
0
class SurfaceLabelSchema(LabelSchema):
    surface = NameEnum(atf.Surface, required=True)
    text = fields.String(dump_default="")

    @post_load
    def make_label(self, data, **kwargs) -> SurfaceLabel:
        return SurfaceLabel(data["status"], data["surface"], data["text"])
Esempio n. 6
0
class ParallelTextSchema(ParallelLineSchema):
    genre = NameEnum(Genre, load_only=True)
    text = fields.Nested(TextIdSchema, required=True)
    chapter = fields.Nested(ChapterNameSchema, required=True, allow_none=True)
    line_number = fields.Nested(
        OneOfLineNumberSchema, required=True, data_key="lineNumber"
    )
    exists = exists()
    implicit_chapter = fields.Nested(
        ChapterNameSchema,
        load_default=None,
        allow_none=True,
        data_key="implicitChapter",
    )

    @post_load
    def make_line(self, data, **kwargs) -> ParallelText:
        return ParallelText(
            data["has_cf"],
            data["text"],
            data["chapter"],
            data["line_number"],
            data["exists"],
            data["implicit_chapter"],
        )
Esempio n. 7
0
class DiscourseAtLineSchema(AtLineSchema):
    discourse_label = NameEnum(atf.Discourse, required=True)
    display_value = fields.String(data_key="displayValue")

    @post_load
    def make_line(self, data, **kwargs) -> DiscourseAtLine:
        return DiscourseAtLine(data["discourse_label"])
Esempio n. 8
0
class EnclosureSchema(BaseTokenSchema):
    side = NameEnum(Side, required=True)

    @abstractmethod
    @post_load
    def make_token(self, data, **kwargs) -> Token:
        ...
Esempio n. 9
0
class LanguagePartSchema(Schema):
    language = NameEnum(Language, required=True)
    tokens = fields.Nested(OneOfTokenSchema, many=True, load_default=None)

    @post_load
    def make_part(self, data, **kwargs) -> LanguagePart:
        return LanguagePart.of_transliteration(data["language"],
                                               data["tokens"])
Esempio n. 10
0
class CompositeAtLineSchema(AtLineSchema):
    composite = NameEnum(atf.Composite, required=True)
    text = fields.String(required=True)
    number = fields.Int(required=False, allow_none=True, dump_default=None)
    display_value = fields.String(data_key="displayValue")

    @post_load
    def make_line(self, data, **kwargs) -> CompositeAtLine:
        return CompositeAtLine(data["composite"], data["text"], data["number"])
Esempio n. 11
0
class LanguageShiftSchema(BaseTokenSchema):
    language = NameEnum(Language, required=True)
    normalized = fields.Boolean(required=True)

    @post_load
    def make_token(self, data, **kwargs):
        return LanguageShift(
            frozenset(data["enclosure_type"]), data["erasure"], data["value"]
        )
class AuthorSchema(Schema):
    name = fields.String(required=True)
    prefix = fields.String(required=True)
    role = NameEnum(AuthorRole, required=True)
    orcid_number = fields.String(required=True, data_key="orcidNumber")

    @post_load
    def make_author(self, data: dict, **kwargs) -> Author:
        return Author(data["name"], data["prefix"], data["role"],
                      data["orcid_number"])
Esempio n. 13
0
class BaseWordSchema(BaseTokenSchema):
    parts = fields.List(fields.Nested(lambda: OneOfTokenSchema()), required=True)
    language = NameEnum(Language, required=True)
    normalized = fields.Boolean(required=True)
    lemmatizable = fields.Boolean(required=True)
    alignable = fields.Boolean()
    unique_lemma = fields.List(fields.String(), data_key="uniqueLemma", required=True)
    alignment = fields.Integer(allow_none=True, load_default=None)
    variant = fields.Nested(
        lambda: OneOfWordSchema(), allow_none=True, load_default=None
    )
class StateDollarLineSchema(DollarLineSchema):
    qualification = NameEnum(atf.Qualification, required=True, allow_none=True)
    extent = fields.Function(
        lambda strict: StateDollarLineSchema.dump_extent(strict.extent),
        lambda value: value,
        required=True,
        allow_none=True,
    )
    scope = fields.Nested(ScopeContainerSchema, required=True, allow_none=True)
    state = NameEnum(atf.State, required=True, allow_none=True)
    status = NameEnum(atf.DollarStatus, required=True, allow_none=True)
    display_value = fields.String(data_key="displayValue")

    @post_load
    def make_line(self, data, **kwargs) -> StateDollarLine:
        return StateDollarLine(
            data["qualification"],
            StateDollarLineSchema.load_extent(data["extent"]),
            data["scope"],
            data["state"],
            data["status"],
        )

    @staticmethod
    def load_extent(extent):
        if isinstance(extent, str):
            return atf.Extent[extent]
        elif isinstance(extent, list):
            return tuple(extent)
        else:
            return extent

    @staticmethod
    def dump_extent(extent):
        if isinstance(extent, atf.Extent):
            return extent.name
        elif isinstance(extent, tuple):
            return list(extent)
        else:
            return extent
Esempio n. 15
0
class ReferenceSchema(Schema):
    id = fields.String(required=True)
    type = NameEnum(ReferenceType, required=True)
    pages = fields.String(required=True)
    notes = fields.String(required=True)
    lines_cited = fields.List(fields.String(),
                              required=True,
                              data_key="linesCited")
    document = fields.Mapping(load_default=None, load_only=True)

    @post_load
    def make_reference(self, data, **kwargs) -> Reference:
        data["id"] = BibliographyId(data["id"])
        data["lines_cited"] = tuple(data["lines_cited"])
        data["document"] = data["document"] and create_object_entry(
            data["document"])
        return Reference(**data)
Esempio n. 16
0
class LabelSchema(Schema):
    status = fields.List(NameEnum(atf.Status), required=True)
    abbreviation = fields.String()
Esempio n. 17
0
class _TestSchemaStr(Schema):
    value = ValueEnum(_TestEnumStr, required=True, allow_none=True)
    name = NameEnum(_TestEnumStr, required=True, allow_none=True)
Esempio n. 18
0
class _TestSchemaInt(Schema):
    value = ValueEnum(_TestEnumInt, required=True, allow_none=True)
    name = NameEnum(_TestEnumInt, required=True, allow_none=True)