fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解
This commit is contained in:
@@ -137,7 +137,7 @@ class MultimodalEntityLinker:
|
||||
"""
|
||||
# 名称相似度
|
||||
name_sim = self.calculate_string_similarity(
|
||||
entity1.get("name", ""), entity2.get("name", "")
|
||||
entity1.get("name", ""), entity2.get("name", ""),
|
||||
)
|
||||
|
||||
# 如果名称完全匹配
|
||||
@@ -158,7 +158,7 @@ class MultimodalEntityLinker:
|
||||
|
||||
# 定义相似度
|
||||
def_sim = self.calculate_string_similarity(
|
||||
entity1.get("definition", ""), entity2.get("definition", "")
|
||||
entity1.get("definition", ""), entity2.get("definition", ""),
|
||||
)
|
||||
|
||||
# 综合相似度
|
||||
@@ -170,7 +170,7 @@ class MultimodalEntityLinker:
|
||||
return combined_sim, "none"
|
||||
|
||||
def find_matching_entity(
|
||||
self, query_entity: dict, candidate_entities: list[dict], exclude_ids: set[str] = None
|
||||
self, query_entity: dict, candidate_entities: list[dict], exclude_ids: set[str] = None,
|
||||
) -> AlignmentResult | None:
|
||||
"""
|
||||
在候选实体中查找匹配的实体
|
||||
@@ -270,7 +270,7 @@ class MultimodalEntityLinker:
|
||||
return links
|
||||
|
||||
def fuse_entity_knowledge(
|
||||
self, entity_id: str, linked_entities: list[dict], multimodal_mentions: list[dict]
|
||||
self, entity_id: str, linked_entities: list[dict], multimodal_mentions: list[dict],
|
||||
) -> FusionResult:
|
||||
"""
|
||||
融合多模态实体知识
|
||||
@@ -388,13 +388,13 @@ class MultimodalEntityLinker:
|
||||
"entities": group,
|
||||
"type": "homonym_conflict",
|
||||
"suggestion": "Consider disambiguating these entities",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
return conflicts
|
||||
|
||||
def suggest_entity_merges(
|
||||
self, entities: list[dict], existing_links: list[EntityLink] = None
|
||||
self, entities: list[dict], existing_links: list[EntityLink] = None,
|
||||
) -> list[dict]:
|
||||
"""
|
||||
建议实体合并
|
||||
@@ -437,7 +437,7 @@ class MultimodalEntityLinker:
|
||||
"similarity": similarity,
|
||||
"match_type": match_type,
|
||||
"suggested_action": "merge" if similarity > 0.95 else "link",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
# 按相似度排序
|
||||
@@ -489,7 +489,7 @@ class MultimodalEntityLinker:
|
||||
Returns:
|
||||
模态分布统计
|
||||
"""
|
||||
distribution = {mod: 0 for mod in self.MODALITIES}
|
||||
distribution = dict.fromkeys(self.MODALITIES, 0)
|
||||
|
||||
# 统计每个模态的实体数
|
||||
for me in multimodal_entities:
|
||||
|
||||
Reference in New Issue
Block a user