Skip to main content
Version: 0.0.5 (stable)

agrag.ingestion.extract.validate_extraction

validate_extraction(result:ExtractionResult, schema:GraphSchema) -> ExtractionResult

Drop entities and relations that the schema does not declare.

The pipeline applies this to the result of every extractor, so a custom extractor cannot send an undeclared label to the graph. An entity survives only when its label is a declared EntityType, and keeps only the property keys that EntityType declares. A relation survives only when both of its entities survive and schema.allows accepts its label and resolved (source label, target label) pair. Property keys the schema does not declare are returned as property candidates. Relation indices are remapped to the surviving entities. A drop is logged with a count.

Parameters:

  • result (ExtractionResult) – The extractor's result, before schema validation.
  • schema (GraphSchema) – The schema entities and relations are validated against.

Returns:

  • ExtractionResult – A copy of result holding only schema-declared entities and
  • ExtractionResult – relations, with relation indices remapped and each entity's properties
  • ExtractionResult – limited to its declared keys. Undeclared properties are candidates.
  • ExtractionResult – Existing candidates and needs_properties are preserved.