Skip to content

Extraction Schemas

Pydantic models for the output of ContractExtractor.

Contract

Contract

Bases: BaseModel

Main contract model representing all extracted data from a legal document.

critical_risks: list[RiskFlag] property

Get only critical risk flags.

high_confidence_clauses: list[Clause] property

Get clauses with confidence >= 0.8.

duration_days: int | None property

Calculate contract duration in days.

to_json(file_path: str | None = None, **kwargs: Any) -> str

Export to JSON format.

Parameters:

Name Type Description Default
file_path str | None

Optional path to save JSON file

None
**kwargs Any

Additional arguments for json.dumps

{}

Returns:

Type Description
str

JSON string representation

to_dict() -> dict[str, Any]

Export to dictionary.

to_dataframe() -> pd.DataFrame

Export to pandas DataFrame (clauses as rows).

Returns:

Type Description
DataFrame

DataFrame with clause information

to_excel(file_path: str) -> None

Export to Excel file.

Parameters:

Name Type Description Default
file_path str

Path to save Excel file

required

compare_with(other: Contract) -> ContractComparison

Compare with another contract.

Parameters:

Name Type Description Default
other Contract

Another Contract instance to compare with

required

Returns:

Type Description
ContractComparison

ContractComparison object with differences

Clause

Clause

Bases: BaseModel

Represents an extracted clause from a contract.

Party

Party

Bases: BaseModel

Represents a party (legal entity) in a contract.

FinancialTerm

FinancialTerm

Bases: BaseModel

Represents financial terms extracted from a contract.

ContractMetadata

ContractMetadata

Bases: BaseModel

Metadata about the contract document and extraction process.