Fix weird Onttology URI issue (#637)

This commit is contained in:
cybermaggedon 2026-02-16 19:18:29 +00:00 committed by GitHub
parent d886358be6
commit 89b69fdb08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -74,23 +74,27 @@ def build_entity_uri(entity_name: str, entity_type: str, ontology_id: str,
Args:
entity_name: Natural language entity name (e.g., "Cornish pasty")
entity_type: Ontology type (e.g., "fo/Recipe")
entity_type: Ontology type (e.g., "fo/Recipe" or "Recipe")
ontology_id: Ontology identifier (e.g., "food")
base_uri: Base URI for entity URIs (default: "https://trustgraph.ai")
Returns:
Full entity URI (e.g., "https://trustgraph.ai/food/fo-recipe-cornish-pasty")
Full entity URI (e.g., "https://trustgraph.ai/food/recipe-cornish-pasty")
Examples:
>>> build_entity_uri("Cornish pasty", "fo/Recipe", "food")
'https://trustgraph.ai/food/fo-recipe-cornish-pasty'
'https://trustgraph.ai/food/recipe-cornish-pasty'
>>> build_entity_uri("Cornish pasty", "fo/Food", "food")
'https://trustgraph.ai/food/fo-food-cornish-pasty'
>>> build_entity_uri("Cornish pasty", "Food", "food")
'https://trustgraph.ai/food/food-cornish-pasty'
>>> build_entity_uri("beef", "fo/Food", "food")
'https://trustgraph.ai/food/fo-food-beef'
'https://trustgraph.ai/food/food-beef'
"""
# Strip ontology prefix from type if present (e.g., "fo/Recipe" -> "Recipe")
if "/" in entity_type:
entity_type = entity_type.split("/")[-1]
type_part = normalize_type_identifier(entity_type)
name_part = normalize_entity_name(entity_name)