ie_schema¶
Classes¶
Classification task definition with labels and threshold metadata. |
|
Entity extraction task definition. |
|
Information-extraction schema loaded from JSON (or from a dataclass / Pydantic model type). |
|
Structured JSON extraction task with named children. |
|
Relation extraction task between head and tail entity types. |
|
Child field in a JSONStructureTask. |
|
Base class for all extraction tasks yielded by IESchema. |
Module Contents¶
- class ie_schema.ClassificationTask¶
Bases:
TaskClassification task definition with labels and threshold metadata.
- property labels: list[str]¶
Ordered list of class labels.
- property multi_label: bool¶
Whether multiple labels may be assigned.
- property task: str¶
Classification task name.
- property threshold: float | None¶
Optional confidence threshold for the classification.
- class ie_schema.EntityExtractionTask¶
Bases:
TaskEntity extraction task definition.
- property entities: list[str]¶
Entity labels that should be extracted.
- class ie_schema.IESchema¶
Information-extraction schema loaded from JSON (or from a dataclass / Pydantic model type).
Build an IESchema from a JSON string with loads() (IE ingest JSON or a root JSON Schema object), from a path with load(), or from a stdlib dataclass / Pydantic v2 BaseModel by passing the class (or an instance) to loads(). Iterating over the object yields task instances in schema order.
Example: >>> import ie_schema >>> _j = ‘{“json_structures”:[{“name”:”Business”,”business_name”:{“dtype”:”str”}}]}’ >>> schema = ie_schema.IESchema.loads(_j) >>> isinstance(schema, ie_schema.IESchema) True >>> len(list(schema)) 1
- classmethod loads(input: Any) IESchema¶
Parse an IESchema from a JSON string or from a dataclass / Pydantic v2 BaseModel type.
String input must be either IE ingest JSON (top-level keys such as json_structures, entities, …) or a root JSON Schema object (type, properties, …). Unknown top-level keys are rejected for the IE shape so JSON Schema is not misread as an empty ingest.
For a dataclass or BaseModel type (or instance), Pydantic v2 builds JSON Schema (TypeAdapter for dataclasses, model_json_schema() for BaseModel subclasses), which is then parsed like JSON Schema string input.
Example: >>> import ie_schema >>> schema = ie_schema.IESchema.loads(‘{“json_structures”:[{“name”:”Business”,”business_name”:{“dtype”:”str”}}]}’) >>> len(list(schema)) 1
- prompt() str¶
Render the generated extraction prompt as a debug string.
Example: >>> import ie_schema >>> schema = ie_schema.IESchema.loads(‘{“json_structures”:[{“name”:”Business”,”business_name”:{“dtype”:”str”}}]}’) >>> s = schema.prompt() >>> (“[P]” in s) and (“business_name” in s) True
- class ie_schema.JSONStructureTask¶
Bases:
TaskStructured JSON extraction task with named children.
- property children: list[StructureChild]¶
Child fields that belong to this structure.
- property name: str¶
Structure name.
- class ie_schema.RelationExtractionTask¶
Bases:
TaskRelation extraction task between head and tail entity types.
- property description: str | None¶
Optional human-readable relation description.
- property head: str¶
Head entity type.
- property name: str¶
Relation name.
- property tail: str¶
Tail entity type.
- class ie_schema.StructureChild¶
Child field in a JSONStructureTask.
- property choices: list[str]¶
Allowed string choices for this property.
- property description: str | None¶
Optional child-field description.
- property property: str¶
Property name for this child field.
- class ie_schema.Task¶
Base class for all extraction tasks yielded by IESchema.