@@ -58,6 +58,7 @@ class LinkedProject:
5858 hierarchy : Dict [str , str ]
5959 all_triples : List [Tuple [str , str , str ]]
6060 topic_index : Dict [str , List [str ]]
61+ relation_index : Dict [Tuple [str , str , str ], Dict [str , Any ]] = field (default_factory = dict )
6162
6263
6364@dataclass
@@ -103,6 +104,7 @@ def link(self) -> LinkedProject:
103104 ontology_index = {self ._norm_code (o .concept ): o for o in self .ontologies }
104105 code_usage : Dict [str , List [ItemNode ]] = {}
105106 all_triples : List [Tuple [str , str , str ]] = []
107+ relation_index : Dict [Tuple [str , str , str ], Dict [str , Any ]] = {}
106108
107109 for item in self .items :
108110 for code in self ._collect_item_codes (item ):
@@ -121,7 +123,17 @@ def link(self) -> LinkedProject:
121123 for chain in item .chains :
122124 # Detecta se template define RELATIONS (chain qualificada)
123125 has_relations = self ._has_chain_relations ()
124- all_triples .extend (chain .to_triples (has_relations = has_relations ))
126+ triples = chain .to_triples (has_relations = has_relations )
127+ all_triples .extend (triples )
128+
129+ relation_type = "qualified" if has_relations else "simple"
130+ chain_location = chain .location or item .location or SourceLocation (Path ("<unknown>" ), 1 , 1 )
131+ for triple in triples :
132+ if triple not in relation_index :
133+ relation_index [triple ] = {
134+ "location" : chain_location ,
135+ "type" : relation_type ,
136+ }
125137
126138 hierarchy : Dict [str , str ] = {}
127139 for ontology in self .ontologies :
@@ -145,6 +157,7 @@ def link(self) -> LinkedProject:
145157 hierarchy = hierarchy ,
146158 all_triples = all_triples ,
147159 topic_index = topic_index ,
160+ relation_index = relation_index ,
148161 )
149162
150163 def _is_a_pairs (self , chain : ChainNode ) -> List [Tuple [str , str ]]:
0 commit comments