35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""EntityCandidate — candidato de entidad extraido por el LLM."""
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
|
|
@dataclass
|
|
class EntityCandidate:
|
|
"""Candidato de entidad extraido por el LLM.
|
|
|
|
Puede venir de un solo chunk o ser el resultado de mergear multiples
|
|
extracciones. `merged_from` rastrea los nombres originales para debugging.
|
|
"""
|
|
|
|
name: str
|
|
name_normalized: str = ""
|
|
type_ref: str = ""
|
|
type_label: str = ""
|
|
attributes: dict = field(default_factory=dict)
|
|
confidence: float = 0.0
|
|
source_chunk_indices: list[int] = field(default_factory=list)
|
|
merged_from: list[str] = field(default_factory=list)
|
|
|
|
def to_dict(self) -> dict:
|
|
"""Serializa el candidato a un diccionario."""
|
|
return {
|
|
"name": self.name,
|
|
"name_normalized": self.name_normalized,
|
|
"type_ref": self.type_ref,
|
|
"type_label": self.type_label,
|
|
"attributes": self.attributes,
|
|
"confidence": self.confidence,
|
|
"source_chunk_indices": self.source_chunk_indices,
|
|
"merged_from": self.merged_from,
|
|
}
|