Merge pull request #318 from zzzcccxx/main
fix: 修改了local search中的relation_counts计数规则
This commit is contained in:
@@ -578,24 +578,20 @@ async def _find_most_related_text_unit_from_entities(
|
|||||||
all_text_units_lookup = {}
|
all_text_units_lookup = {}
|
||||||
for index, (this_text_units, this_edges) in enumerate(zip(text_units, edges)):
|
for index, (this_text_units, this_edges) in enumerate(zip(text_units, edges)):
|
||||||
for c_id in this_text_units:
|
for c_id in this_text_units:
|
||||||
if c_id in all_text_units_lookup:
|
if c_id not in all_text_units_lookup:
|
||||||
continue
|
all_text_units_lookup[c_id] = {
|
||||||
relation_counts = 0
|
"data": await text_chunks_db.get_by_id(c_id),
|
||||||
if this_edges: # Add check for None edges
|
"order": index,
|
||||||
|
"relation_counts": 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
if this_edges:
|
||||||
for e in this_edges:
|
for e in this_edges:
|
||||||
if (
|
if (
|
||||||
e[1] in all_one_hop_text_units_lookup
|
e[1] in all_one_hop_text_units_lookup
|
||||||
and c_id in all_one_hop_text_units_lookup[e[1]]
|
and c_id in all_one_hop_text_units_lookup[e[1]]
|
||||||
):
|
):
|
||||||
relation_counts += 1
|
all_text_units_lookup[c_id]["relation_counts"] += 1
|
||||||
|
|
||||||
chunk_data = await text_chunks_db.get_by_id(c_id)
|
|
||||||
if chunk_data is not None and "content" in chunk_data: # Add content check
|
|
||||||
all_text_units_lookup[c_id] = {
|
|
||||||
"data": chunk_data,
|
|
||||||
"order": index,
|
|
||||||
"relation_counts": relation_counts,
|
|
||||||
}
|
|
||||||
|
|
||||||
# Filter out None values and ensure data has content
|
# Filter out None values and ensure data has content
|
||||||
all_text_units = [
|
all_text_units = [
|
||||||
|
Reference in New Issue
Block a user