Skip to main content

agrag.ingestion.resolve.candidate_source.build_relation_neighbors

build_relation_neighbors(entities:list[ExtractedEntity], relations:Sequence[ExtractedRelation], *, max_neighbors:int = MAX_NEIGHBORS_PER_ENTITY) -> dict[int, list[str]]

Build LLMVerify neighbor context from one batch's extracted relations.

Parameters:

  • entities (list[ExtractedEntity]) – The batch's mentions, indexed as relations references them.
  • relations (Sequence[ExtractedRelation]) – Relation mentions from the same extraction batch.
  • max_neighbors (int) – Maximum neighbor strings kept per entity index.

Returns:

  • dict[int, list[str]] – Entity index to a list of "{relation_label} {other_entity_text}"
  • dict[int, list[str]] – strings, each direction of a relation contributing one entry to
  • dict[int, list[str]] – both endpoints, capped at max_neighbors per index. An index with no
  • dict[int, list[str]] – relation names has no key at all.