Skip to content

Commit

Permalink
Add metadata for urn:cite2:beyond-translation:text_annotation_collect…
Browse files Browse the repository at this point in the history
…ion.atlas_v1:amedsaid1831-hilleary
  • Loading branch information
jacobwegner committed Dec 28, 2023
1 parent 89363be commit dab4aee
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/scaife_stack_atlas/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
"scaife_stack_atlas.temp.ingest_balex_extras",
"scaife_stack_atlas.temp.update_balex_metadata",
"scaife_stack_atlas.temp.load_boano_metadata",
"scaife_stack_atlas.temp.load_hilleary_metadata",
"scaife_stack_atlas.temp.add_cgl_css",
]
DB_DATA_PATH = os.environ.get("DB_DATA_PATH", PROJECT_ROOT)
Expand Down
47 changes: 47 additions & 0 deletions backend/scaife_stack_atlas/temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,53 @@ def load_boano_metadata(reset=False):
)
)
AttributionRecord.objects.bulk_create(attribution_records)


def load_hilleary_metadata(reset=False):
path = (
Path(settings.SV_ATLAS_DATA_DIR)
/ "annotations/syntax-trees/amedsaid1831-hilleary/metadata.yml"
)
data = yaml.safe_load(path.read_text())
collection_urn = data["urn"]
if reset:
TextAnnotation.objects.filter(collection__urn=collection_urn).update(
collection=None
)
TextAnnotationCollection.objects.filter(urn=collection_urn).delete()

tas = TextAnnotation.objects.filter(
urn__istartswith="urn:cite2:scaife-viewer:syntaxTree.v1:syntaxTree-amedsaid1831-dw042-perseus-eng1"
)
collection = TextAnnotationCollection.objects.create(
label=data["label"],
data={
"source": data["source"],
"fields": data["fields"],
},
urn=collection_urn,
)
tas.update(collection=collection)

attribution_records = []
for record in data.get("metadata", {}).get("attributions", []):
person, _ = AttributionPerson.objects.get_or_create(name=record["name"])
organization_data = record.get("organization")
if organization_data:
organization, _ = AttributionOrganization.objects.get_or_create(
name=organization_data["name"]
)
attribution_records.append(
AttributionRecord(
person=person,
organization=organization,
role="Annotator",
data=dict(references=[list(tas.values_list("urn"))]),
)
)
AttributionRecord.objects.bulk_create(attribution_records)


def set_text_annotation_collection(reset=False):
# TODO: Reset is a no-op
collection_urn = "urn:cite2:beyond-translation:text_annotation_collection.atlas_v1:il_gregorycrane_gAGDT"
Expand Down

0 comments on commit dab4aee

Please sign in to comment.