-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into debug-corpus-search
- Loading branch information
Showing
30 changed files
with
576 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from ebl.common.domain.named_enum import NamedEnum | ||
|
||
|
||
class ProvenanceEnum(NamedEnum): | ||
def __init__(self, long_name, abbreviation, parent, cigs_key, sort_key=-1): | ||
super().__init__(long_name, abbreviation, sort_key) | ||
self.parent = parent | ||
self.cigs_key = cigs_key | ||
|
||
|
||
class Provenance(ProvenanceEnum): | ||
STANDARD_TEXT = ("Standard Text", "Std", None, None) | ||
ASSYRIA = ("Assyria", "Assa", None, None) | ||
ASSUR = ("Aššur", "Ašš", "Assyria", "ASS") | ||
HUZIRINA = ("Ḫuzirina", "Huz", "Assyria", "HUZ") | ||
KALHU = ("Kalḫu", "Kal", "Assyria", "NIM") | ||
KHORSABAD = ("Khorsabad", "Kho", "Assyria", "SAR") | ||
NINEVEH = ("Nineveh", "Nin", "Assyria", "NNV") | ||
TARBISU = ("Tarbiṣu", "Tar", "Assyria", "SKH") | ||
BABYLONIA = ("Babylonia", "Baba", None, None) | ||
BABYLON = ("Babylon", "Bab", "Babylonia", "BAB") | ||
BORSIPPA = ("Borsippa", "Bor", "Babylonia", "BOR") | ||
CUTHA = ("Cutha", "Cut", "Babylonia", "GUD") | ||
DILBAT = ("Dilbat", "Dil", "Babylonia", "DLB") | ||
ISIN = ("Isin", "Isn", "Babylonia", "ISN") | ||
KIS = ("Kiš", "Kiš", "Babylonia", "KSH") | ||
LARSA = ("Larsa", "Lar", "Babylonia", "LAR") | ||
METURAN = ("Meturan", "Met", "Babylonia", "HDD") | ||
NEREBUN = ("Nērebtum", "Nēr", "Babylonia", "NRB") | ||
NIPPUR = ("Nippur", "Nip", "Babylonia", "NIP") | ||
SIPPAR = ("Sippar", "Sip", "Babylonia", "SAP") | ||
SADUPPUM = ("Šaduppûm", "Šad", "Babylonia", "SDP") | ||
UR = ("Ur", "Ur", "Babylonia", "URI") | ||
URUK = ("Uruk", "Urk", "Babylonia", "URU") | ||
PERIPHERY = ("Periphery", "", None, None) | ||
ALALAKS = ("Alalakh", "Ala", "Periphery", "ALA") | ||
TELL_EL_AMARNA = ("Tell el-Amarna", "Ama", "Periphery", "AKH") | ||
EMAR = ("Emar", "Emr", "Periphery", "EMR") | ||
HATTUSA = ("Ḫattuša", "Hat", "Periphery", "HAT") | ||
MARI = ("Mari", "Mar", "Periphery", "MAR") | ||
MEGIDDO = ("Megiddo", "Meg", "Periphery", "MGD") | ||
SUSA = ("Susa", "Sus", "Periphery", "SUS") | ||
UGARIT = ("Ugarit", "Uga", "Periphery", "UGA") | ||
UNCERTAIN = ("Uncertain", "Unc", None, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from ebl.bibliography.application.reference_schema import ReferenceSchema | ||
from ebl.fragmentarium.application.date_schemas import ( | ||
DateRangeSchema, | ||
DateWithNotesSchema, | ||
) | ||
from ebl.fragmentarium.domain.archaeology import Archaeology | ||
from ebl.fragmentarium.domain.findspot import BuildingType, ExcavationPlan, Findspot | ||
from ebl.schemas import NameEnumField | ||
from marshmallow import Schema, fields, post_load, validate | ||
from ebl.transliteration.domain.museum_number import MuseumNumber as ExcavationNumber | ||
from ebl.corpus.domain.provenance import Provenance as ExcavationSite | ||
|
||
|
||
class ExcavationNumberSchema(Schema): | ||
prefix = fields.String( | ||
required=True, validate=(validate.Length(min=1), validate.ContainsNoneOf(".")) | ||
) | ||
number = fields.String( | ||
required=True, validate=(validate.Length(min=1), validate.ContainsNoneOf(".")) | ||
) | ||
suffix = fields.String(required=True, validate=validate.ContainsNoneOf(".")) | ||
|
||
@post_load | ||
def create_excavation_number(self, data, **kwargs) -> ExcavationNumber: | ||
return ExcavationNumber(**data) | ||
|
||
|
||
class ExcavationPlanSchema(Schema): | ||
svg = fields.String() | ||
references = fields.Nested(ReferenceSchema, many=True, load_default=tuple()) | ||
|
||
@post_load | ||
def create_excavation_plan(self, data, **kwargs) -> ExcavationPlan: | ||
data["references"] = tuple(data["references"]) | ||
return ExcavationPlan(**data) | ||
|
||
|
||
class FindspotSchema(Schema): | ||
area = fields.String() | ||
building = fields.String() | ||
building_type = NameEnumField(BuildingType, data_key="buildingType") | ||
lavel_layer_phase = fields.String(data_key="lavelLayerPhase") | ||
date_range = fields.Nested(DateRangeSchema, data_key="dateRange") | ||
plans = fields.Nested(ExcavationPlanSchema, many=True, load_default=tuple()) | ||
room = fields.String() | ||
context = fields.String() | ||
primary_context = fields.Boolean(data_key="primaryContext") | ||
notes = fields.String() | ||
references = fields.Nested(ReferenceSchema, many=True, load_default=tuple()) | ||
|
||
@post_load | ||
def create_findspot(self, data, **kwargs) -> Findspot: | ||
data["plans"] = tuple(data["plans"]) | ||
data["references"] = tuple(data["references"]) | ||
return Findspot(**data) | ||
|
||
|
||
class ArchaeologySchema(Schema): | ||
excavation_number = fields.Nested( | ||
ExcavationNumberSchema, data_key="excavationNumber", allow_none=True | ||
) | ||
site = fields.Function( | ||
lambda archaeology: getattr(archaeology.site, "long_name", None), | ||
lambda value: ExcavationSite.from_name(value), | ||
allow_none=True, | ||
) | ||
regular_excavation = fields.Boolean( | ||
load_default=True, data_key="isRegularExcavation" | ||
) | ||
excavation_date = fields.Nested( | ||
DateWithNotesSchema, data_key="excavationDate", many=True, load_default=tuple() | ||
) | ||
findspot = fields.Nested(FindspotSchema, allow_none=True, default=None) | ||
|
||
@post_load | ||
def create_archaeology(self, data, **kwargs) -> Archaeology: | ||
data["excavation_date"] = tuple(data["excavation_date"]) | ||
return Archaeology(**data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import datetime | ||
from ebl.fragmentarium.domain.iso_date import DateRange, DateWithNotes | ||
from marshmallow import Schema, fields, post_load | ||
from dateutil.parser import isoparse | ||
|
||
|
||
class IsoDateField(fields.Field): | ||
def _serialize(self, date: datetime.date, *args, **kwargs) -> str: | ||
return str(date) | ||
|
||
def _deserialize(self, date_string: str, *args, **kwargs) -> datetime.date: | ||
return isoparse(date_string).date() | ||
|
||
|
||
class DateRangeSchema(Schema): | ||
start = IsoDateField() | ||
end = IsoDateField() | ||
notes = fields.String() | ||
|
||
@post_load | ||
def create_date_range(self, data, **kwargs) -> DateRange: | ||
return DateRange(**data) | ||
|
||
|
||
class DateWithNotesSchema(Schema): | ||
date = IsoDateField() | ||
notes = fields.String() | ||
|
||
@post_load | ||
def create_date(self, data, **kwargs) -> DateWithNotes: | ||
return DateWithNotes(**data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import Optional, Sequence | ||
import attr | ||
from ebl.fragmentarium.domain.iso_date import DateWithNotes | ||
from ebl.fragmentarium.domain.findspot import Findspot | ||
from ebl.transliteration.domain.museum_number import MuseumNumber as ExcavationNumber | ||
from ebl.corpus.domain.provenance import Provenance as ExcavationSite | ||
|
||
|
||
@attr.s(auto_attribs=True, frozen=True) | ||
class Archaeology: | ||
excavation_number: Optional[ExcavationNumber] = None | ||
site: Optional[ExcavationSite] = None | ||
regular_excavation: bool = True | ||
excavation_date: Sequence[DateWithNotes] = tuple() | ||
findspot: Optional[Findspot] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import attr | ||
from typing import Optional, Sequence | ||
from enum import Enum, auto | ||
from ebl.bibliography.domain.reference import Reference | ||
from ebl.fragmentarium.domain.iso_date import DateRange | ||
|
||
|
||
class BuildingType(Enum): | ||
RESIDENTIAL = auto() | ||
TEMPLE = auto() | ||
PALACE = auto() | ||
OTHER_MONUMENTAL = auto() | ||
UNKNOWN = auto() | ||
NOT_IN_BUILDING = auto() | ||
|
||
|
||
@attr.s(auto_attribs=True, frozen=True) | ||
class ExcavationPlan: | ||
svg: str | ||
references: Sequence[Reference] = tuple() | ||
|
||
|
||
@attr.s(auto_attribs=True, frozen=True) | ||
class Findspot: | ||
area: str = "" | ||
building: str = "" | ||
building_type: Optional[BuildingType] = None | ||
lavel_layer_phase: str = "" | ||
date_range: Optional[DateRange] = None | ||
plans: Sequence[ExcavationPlan] = tuple() | ||
room: str = "" | ||
context: str = "" | ||
primary_context: Optional[bool] = None | ||
notes: str = "" | ||
references: Sequence[Reference] = tuple() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import attr | ||
import datetime | ||
|
||
|
||
@attr.s(auto_attribs=True, frozen=True) | ||
class DateRange: | ||
start: datetime.date | ||
end: datetime.date | ||
notes: str = "" | ||
|
||
|
||
@attr.s(auto_attribs=True, frozen=True) | ||
class DateWithNotes: | ||
date: datetime.date | ||
notes: str = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.