Skip to content

Commit ae2340c

Browse files
damienriehlclaude
andcommitted
fix: include translations and synonyms in index path class detail
The index path was only returning rdfs:label as labels and excluding all LABEL_PROPERTIES (skos:altLabel, skos:prefLabel, etc.) from annotations. This caused translations and synonyms stored as skos:altLabel to be invisible in browse mode. Fix: include non-rdfs:label entries from indexed_labels as annotations, matching the RDFLib fallback path behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b458c24 commit ae2340c

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

ontokit/services/ontology_index.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,12 @@ async def get_class_detail(
654654
# Return None so the frontend can distinguish "not indexed" from "zero".
655655
instance_count = None
656656

657-
# Get annotations (excluding rdfs:comment and label properties
658-
# which are already returned via IndexedLabel)
659-
label_property_iris = {str(uri) for _, uri in LABEL_PROPERTIES}
660-
excluded_iris = label_property_iris | {rdfs_comment_iri}
657+
# Get annotations from IndexedAnnotation (excludes rdfs:comment which
658+
# is returned separately as `comments`)
661659
annotations_result = await self.db.execute(
662660
select(IndexedAnnotation).where(
663661
IndexedAnnotation.entity_id == entity.id,
664-
IndexedAnnotation.property_iri.notin_(excluded_iris),
662+
IndexedAnnotation.property_iri != rdfs_comment_iri,
665663
)
666664
)
667665
annotations_by_prop: dict[str, list[dict[str, str]]] = {}
@@ -676,6 +674,25 @@ async def get_class_detail(
676674
}
677675
)
678676

677+
# Also include non-rdfs:label entries from IndexedLabel as annotations
678+
# (skos:altLabel, skos:prefLabel, dcterms:title — these are translations/synonyms)
679+
non_rdfs_labels_result = await self.db.execute(
680+
select(IndexedLabel).where(
681+
IndexedLabel.entity_id == entity.id,
682+
IndexedLabel.property_iri != rdfs_label_iri,
683+
)
684+
)
685+
for lbl in non_rdfs_labels_result.scalars().all():
686+
key = lbl.property_iri
687+
if key not in annotations_by_prop:
688+
annotations_by_prop[key] = []
689+
annotations_by_prop[key].append(
690+
{
691+
"value": lbl.value,
692+
"lang": lbl.lang or "",
693+
}
694+
)
695+
679696
# Build annotation property list matching the response format
680697
annotation_list = []
681698
for prop_iri, values in annotations_by_prop.items():

0 commit comments

Comments
 (0)