mirror of
https://github.com/microsoft/graphrag.git
synced 2025-11-14 00:55:00 +00:00
Fix weight casting during graph extraction (#1016)
* Fix weight casting during graph extraction * Format * Format
This commit is contained in:
parent
e15df44f0d
commit
55e74a0c2e
@ -0,0 +1,4 @@
|
||||
{
|
||||
"type": "patch",
|
||||
"description": "Fix weight casting during graph extraction"
|
||||
}
|
||||
@ -4,7 +4,6 @@
|
||||
"""A module containing 'GraphExtractionResult' and 'GraphExtractor' models."""
|
||||
|
||||
import logging
|
||||
import numbers
|
||||
import re
|
||||
import traceback
|
||||
from collections.abc import Mapping
|
||||
@ -248,11 +247,11 @@ class GraphExtractor:
|
||||
target = clean_str(record_attributes[2].upper())
|
||||
edge_description = clean_str(record_attributes[3])
|
||||
edge_source_id = clean_str(str(source_doc_id))
|
||||
weight = (
|
||||
float(record_attributes[-1])
|
||||
if isinstance(record_attributes[-1], numbers.Number)
|
||||
else 1.0
|
||||
)
|
||||
try:
|
||||
weight = float(record_attributes[-1])
|
||||
except ValueError:
|
||||
weight = 1.0
|
||||
|
||||
if source not in graph.nodes():
|
||||
graph.add_node(
|
||||
source,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user