From 07e36a114ade61f60b8d5d29b690b1dc69bade1a Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 1 Nov 2023 16:23:19 +0100 Subject: [PATCH] folia2stam: minor syntax fixes --- foliatools/folia2stam.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/foliatools/folia2stam.py b/foliatools/folia2stam.py index 785397d..b8ab158 100644 --- a/foliatools/folia2stam.py +++ b/foliatools/folia2stam.py @@ -97,7 +97,8 @@ def convert_tokens(doc: folia.Document, annotationstore: stam.AnnotationStore, * data=token["data"]) word_folia = doc[token["id"]] - convert_inline_annotation(word_folia, word_stam, annotationstore, **kwargs ) + if word_folia: + convert_inline_annotation(word_folia, word_stam, annotationstore, **kwargs ) return resource @@ -404,11 +405,13 @@ def convert_type_information(annotation: folia.AbstractElement) -> Generator[dic "key": "elementtype", "value": annotation.XMLTAG} if annotation.ANNOTATIONTYPE: - value = folia.annotationtype2str(annotation.ANNOTATIONTYPE).lower() - yield {"set": FOLIA_NAMESPACE, - "id":f"{FOLIA_NAMESPACE}annotationtype/{value}", - "key":"annotationtype", - "value":value} + value = folia.annotationtype2str(annotation.ANNOTATIONTYPE) + if value: + value = value.lower() + yield {"set": FOLIA_NAMESPACE, + "id":f"{FOLIA_NAMESPACE}annotationtype/{value}", + "key":"annotationtype", + "value":value} def convert_common_attributes(annotation: folia.AbstractElement) -> Generator[dict,None,None]: """Convert common FoLiA attributes"""