From d6db80588577f047a565af8f6fa862e14f0ca45f Mon Sep 17 00:00:00 2001 From: lidp <43509927+guoyuhao2330@users.noreply.github.com> Date: Mon, 30 Sep 2024 17:18:09 +0800 Subject: [PATCH] Refactoring entity_resolution (#2692) ### What problem does this PR solve? ### Type of change - [x] Refactoring --- graphrag/entity_resolution.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/graphrag/entity_resolution.py b/graphrag/entity_resolution.py index b3398015a9..3fd7f4fbf0 100644 --- a/graphrag/entity_resolution.py +++ b/graphrag/entity_resolution.py @@ -94,11 +94,7 @@ def __call__(self, graph: nx.Graph, prompt_variables: dict[str, Any] | None = No candidate_resolution = {entity_type: [] for entity_type in entity_types} for k, v in node_clusters.items(): - candidate_resolution_tmp = [] - for a, b in itertools.permutations(v, 2): - if self.is_similarity(a, b) and (b, a) not in candidate_resolution_tmp: - candidate_resolution_tmp.append((a, b)) - candidate_resolution[k] = candidate_resolution_tmp + candidate_resolution[k] = [(a, b) for a, b in itertools.combinations(v, 2) if self.is_similarity(a, b)] gen_conf = {"temperature": 0.5} resolution_result = set()