ie-schema 0.1.5

A flexible schema specification and parser for information extraction tasks.
Documentation

Crates.io PyPI Build Latest Release Documentation Dependency Status Docs

Information Extraction Schema

A flexible input schema for GLiNER style multi-task models.

Python

uv add ie_schema  # or pip install
# To load from dataclasses / Pydantic models, install the optional dependency:
uv add 'ie_schema[model]'
from dataclasses import dataclass
from ie_schema import IESchema

@dataclass
class BusinessRecord:
    business_name: str
    address_line1: str
    address_line2: str | None
    email: str | None
    website: str | None
    phone: str | None

# From raw JSON (native ie-schema format):
schema = IESchema.loads(
    '{"json_structures":[{"name":"BusinessRecord","business_name":{"dtype":"str"}}]}'
)

# Or a root JSON Schema string (scalar object properties only in this conversion):
schema_from_js = IESchema.loads(
    '{"type":"object","properties":{"business_name":{"type":"string"}}}'
)

# Or pass a dataclass / Pydantic v2 model class or instance
# (requires `pydantic` — use the `model` extra):
from_schema = IESchema.loads(BusinessRecord)
from_instance = IESchema.loads(BusinessRecord("Acme", "Main", None, None, None, None))
print(schema, from_schema, from_instance)

Rust

cargo add ie-schema