Skip to content

Commit 01d31c2

Browse files
author
kaldan007
committed
fix(hfml-serializer): subtext serializer bug fix
1 parent 5296ebd commit 01d31c2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

openpecha/serializers/serialize.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,13 @@ def apply_index(self):
210210
for ann_id, topic in self.index_layer["annotations"].items():
211211
topic_ann = defaultdict(str)
212212
sub_topics = topic["parts"]
213-
for i, sub_topic in enumerate(sub_topics):
214-
if sub_topic:
215-
vol_id = f"v{sub_topic['span']['vol']:03}"
216-
sub_topic["type"] = AnnType.sub_topic
217-
if sub_topic["work_id"] != sub_topics[i - 1]["work_id"]:
218-
self.apply_annotation(vol_id, sub_topic)
213+
for sub_topic_uuid, sub_topic in sub_topics.items():
214+
sub_topic_ann = defaultdict(str)
215+
vol_id = f"v{sub_topic['span'][0]['vol']:03}"
216+
sub_topic_ann["type"] = AnnType.sub_topic
217+
sub_topic_ann["work_id"] = sub_topic["work_id"]
218+
sub_topic_ann["span"] = sub_topic['span'][0]
219+
self.apply_annotation(vol_id, sub_topic_ann)
219220
if topic["span"]:
220221
vol_id = f"v{topic['span'][0]['vol']:03}"
221222
topic_ann["type"] = AnnType.topic

tests/data/serialize/hfml/opf/P000003.opf/index.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ annotation_type: index
33
revision: '00001'
44
annotations:
55
12590fb37da14c32ba0785f7f68c6f5e:
6-
parts: []
6+
parts: {}
77
span:
88
- vol: 1
99
start: 0
@@ -13,7 +13,7 @@ annotations:
1313
end: 218
1414
work_id: D1118
1515
ac26bb9b4a034a0fa959ecc6af68fa0e:
16-
parts: []
16+
parts: {}
1717
span:
1818
- vol: 2
1919
start: 218

0 commit comments

Comments
 (0)