@@ -249,7 +249,7 @@ def property_semantic_similarity_mappings(self, property_str: str) -> List[tuple
249249 def property_suggestion_with_so (self ,
250250 subjects : dict = None ,
251251 objects : dict = None
252- ) -> dict :
252+ ) -> List [ tuple [ str , float ]] :
253253 """
254254 Property suggestion with subject and object pairs based on the ontology.
255255 This implementation directly follows the provided pseudocode.
@@ -264,7 +264,6 @@ def property_suggestion_with_so(self,
264264 objects = {}
265265
266266 # This dictionary will store the final suggested properties and their scores.
267- # Corresponds to: 13: ... suggestedProperties
268267 suggestedProperties : dict [str , float ] = {}
269268
270269 # We iterate through all combinations of subjects and objects
@@ -297,7 +296,9 @@ def property_suggestion_with_so(self,
297296 (avg_score > suggestedProperties [prop_iri ]):
298297 suggestedProperties [prop_iri ] = avg_score
299298
300- return suggestedProperties
299+ # turn the dict to list of tuples in form of (iri, score)
300+ suggestedProperties_list = [(iri , score ) for iri , score in suggestedProperties .items ()]
301+ return suggestedProperties_list
301302
302303 def _find_properties (self , subject_iri , object_iri ) -> List [str ]:
303304 """
@@ -485,12 +486,9 @@ def suggest_property_class(self,
485486 res_str = self .suggestion_condition_top_matches (n = 3 , mappings = mappings )
486487
487488 # prepare final results
488- res = {}
489- for iri , score in res_str .items ():
490- if score >= self .threshold_property :
491- res .update ({iri : score })
492- res .update (self .property_suggestion_with_so (subjects , objects ))
493- return res
489+ res = [(iri , score ) for iri , score in res_str .items () if score >= self .threshold_property ]
490+ res .extend (self .property_suggestion_with_so (subjects , objects ))
491+ return self .suggestion_condition_top_matches (n = 10 , mappings = res )
494492
495493 def get_candidate_property_classes (self ,
496494 subject_c : List [str ],
0 commit comments