Skip to content

Commit

Permalink
folia2stam: convert declarations as annotations on datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Nov 1, 2023
1 parent 517e8d0 commit 7a29c5c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions foliatools/folia2stam.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ def convert(f, annotationstore: stam.AnnotationStore, **kwargs):
for key, value in doc.metadata.items():
annotationstore.annotate(target=selector, data={"key":key,"value":value,"set":"metadata"}) #TODO: make metadata set configurable

for annotationtype, foliaset in doc.annotations:
if foliaset:
try:
dataset = annotationstore.dataset(foliaset)
except stam.StamError:
dataset = annotationstore.add_dataset(foliaset)
selector = stam.Selector.datasetselector(dataset)
value = folia.annotationtype2str(annotationtype)
if value:
value = value.lower()
annotationstore.annotate(target=selector, data=[{"key":"declaration", "value": f"{value}-annotation", "set": FOLIA_NAMESPACE},{"key":"annotationtype", "value": value, "set": FOLIA_NAMESPACE}])



def convert_tokens(doc: folia.Document, annotationstore: stam.AnnotationStore, **kwargs) -> stam.TextResource:
"""Convert FoLiA tokens (w) and text content to STAM. Returns a STAM resource"""
Expand Down

0 comments on commit 7a29c5c

Please sign in to comment.