mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-19 20:35:13 +02:00
Fix weird Onttology URI issue (#637)
This commit is contained in:
parent
d886358be6
commit
89b69fdb08
1 changed files with 10 additions and 6 deletions
|
|
@ -74,23 +74,27 @@ def build_entity_uri(entity_name: str, entity_type: str, ontology_id: str,
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
entity_name: Natural language entity name (e.g., "Cornish pasty")
|
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")
|
ontology_id: Ontology identifier (e.g., "food")
|
||||||
base_uri: Base URI for entity URIs (default: "https://trustgraph.ai")
|
base_uri: Base URI for entity URIs (default: "https://trustgraph.ai")
|
||||||
|
|
||||||
Returns:
|
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:
|
Examples:
|
||||||
>>> build_entity_uri("Cornish pasty", "fo/Recipe", "food")
|
>>> 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")
|
>>> build_entity_uri("Cornish pasty", "Food", "food")
|
||||||
'https://trustgraph.ai/food/fo-food-cornish-pasty'
|
'https://trustgraph.ai/food/food-cornish-pasty'
|
||||||
|
|
||||||
>>> build_entity_uri("beef", "fo/Food", "food")
|
>>> 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)
|
type_part = normalize_type_identifier(entity_type)
|
||||||
name_part = normalize_entity_name(entity_name)
|
name_part = normalize_entity_name(entity_name)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue