Skip to content

Taxonomy

Clause types, jurisdictions and authority levels, and the keyword classifier that labels text with CUAD clause types.

CUADClauseType

Bases: str, Enum

CUAD clause type enumeration.

Based on the CUAD dataset: https://www.atticusprojectai.org/cuad

get_description(clause_type: CUADClauseType) -> str classmethod

Get human-readable description of a clause type.

Parameters:

Name Type Description Default
clause_type CUADClauseType

CUAD clause type

required

Returns:

Type Description
str

Description of the clause type

to_storage_type(cuad_type: CUADClauseType) -> str classmethod

Map a fine-grained CUAD clause type to the broader storage.ClauseType vocabulary.

Parameters:

Name Type Description Default
cuad_type CUADClauseType

A CUADClauseType enum member

required

Returns:

Type Description
str

The matching storage ClauseType value string, or "other" if no

str

mapping exists.

get_all_types() -> list classmethod

Get list of all CUAD clause types.

get_high_risk_types() -> list classmethod

Get clause types that typically represent higher risk.

CUADClassifier

Classifier for categorizing contract clauses according to CUAD taxonomy.

CUAD (Contract Understanding Atticus Dataset) defines 41 common clause types found in commercial contracts.

Classification uses keyword-based rules. Set use_llm=True and provide an LLM provider to augment with LLM-based classification (not yet implemented — contributions welcome).

__init__(clause_types: list[str] | None = None, multi_label: bool = True, confidence_threshold: float = 0.5, use_llm: bool = False)

Initialize the CUAD classifier.

Parameters:

Name Type Description Default
clause_types list[str] | None

Specific clause types to classify (None = all CUAD types)

None
multi_label bool

Whether a clause can have multiple types

True
confidence_threshold float

Confidence score assigned to keyword matches

0.5
use_llm bool

Reserved for future LLM-based classification (currently ignored)

False

classify(contract: Contract) -> list[Clause]

Classify all clauses in a contract.

Parameters:

Name Type Description Default
contract Contract

Contract with clauses to classify

required

Returns:

Type Description
list[Clause]

List of classified clauses with updated clause_type

classify_clause(clause: Clause) -> Clause

Classify a single clause using keyword matching.

The first matching type is assigned to clause.clause_type. When multi_label=True, all matches are stored in clause.metadata["all_types"].

Parameters:

Name Type Description Default
clause Clause

Clause to classify

required

Returns:

Type Description
Clause

Clause with updated clause_type, confidence, and metadata

classify_text(text: str) -> list[str]

Classify arbitrary text into CUAD clause types using keyword matching.

Parameters:

Name Type Description Default
text str

Text to classify

required

Returns:

Type Description
list[str]

List of matching clause type values ordered by first keyword hit

JurisdictionTag

Bases: BaseModel

Structured representation of a legal jurisdiction.

Attributes

country: ISO 3166-1 alpha-2 country code (e.g. "US", "DE", "GB"). Use "INT" for international / supranational sources. region: State, province, or Bundesland code (e.g. "CA", "BY"). None means the source applies nationally / federally. court_system: Type of authority: "federal", "state", "administrative", "international", or "other". applicability: "binding" — creates binding obligations. "persuasive" — treated as persuasive (e.g. foreign case cited for reasoning). "informational" — background or educational only.

is_broader_than(other: JurisdictionTag) -> bool

Return True when self has wider geographic scope than other.

Rules
  • Same country, self has no region, other has a region → self is broader.
  • International (country="INT") is broader than any national source.
  • Different countries → not comparable (returns False).

conflicts_with(other: JurisdictionTag) -> bool

Return True when the two tags describe the same country but different regions — a signal that the sources may give conflicting answers.

Intended for use by ConflictDetector.

matches(query_filter: JurisdictionTag) -> bool

Return True when self is compatible with query_filter.

Compatibility rules (used for hard filtering in RAG query)
  • Country must match (or filter country is "INT" — matches all).
  • If the filter specifies a region, self must match that region or have no region (federal/national sources match any state query).
  • Applicability must be "binding" when the filter is "binding".

from_string(s: str) -> JurisdictionTag classmethod

Parse a legacy flat jurisdiction string.

Supported formats::

"US"          → country=US, region=None
"US-Federal"  → country=US, court_system=federal, region=None
"US-CA"       → country=US, region=CA
"DE-BY"       → country=DE, region=BY
"EU"          → country=INT (EU treated as international)

AuthorityLevel

Bases: IntEnum

Ordinal authority weights for legal source types.

Higher values indicate greater authority. These values are used as a multiplier in retrieval ranking alongside vector similarity.

Notes

  • REGULATION (85) sits above APPELLATE_COURT (75) because primary legislation that has been implemented as regulation is binding in most common-law jurisdictions. This can be overridden per deployment.
  • BINDING_TREATY (88) is placed between REGULATION and SUPREME_COURT — binding under international law but may require domestic implementing legislation.
  • AGENCY_GUIDANCE (55) is non-binding but carries more weight than secondary literature.

normalised: float property

Map [1, 100] to [0.01, 1.00] for use in weighted scoring.

is_binding() -> bool

Return True if this level represents a binding legal source.

AuthorityProfile

Bases: BaseModel

Authority metadata attached to every LegalDoc.

Attributes

level: The AuthorityLevel ordinal for this source. jurisdiction: Structured jurisdiction tag (country / region / court system). court_name: Specific court or issuing body (e.g. "9th Circuit Court of Appeals"). is_binding: True when this source creates binding obligations (as opposed to persuasive authority). Derived automatically from level if not supplied. is_superseded: True when this ruling or statute has been overruled, repealed, or amended to the point of irrelevance. Superseded documents are excluded from primary RAG context but retained for historical queries. superseded_by: Citation string of the source that superseded this one. publication_year: Year of publication / decision. Used for recency weighting.

authority_weight: float property

Normalised authority weight [0.01, 1.00].

model_post_init(__context: Any) -> None

Derive is_binding from level when not explicitly set.

for_level(level: AuthorityLevel | str | int, *, jurisdiction: JurisdictionTag | None = None, court_name: str | None = None, publication_year: int | None = None) -> AuthorityProfile classmethod

Convenience constructor — creates a profile for a given authority level.