compass.extraction.date.DateExtractor#

class DateExtractor(json_llm_caller, text_splitter=None)[source]#

Bases: object

Helper class to extract date info from document

Parameters:
  • json_llm_caller (JSONFromTextLLMCaller) – Instance used for structured validation queries.

  • text_splitter (TextSplitter, optional) – Optional text splitter (or subclass instance, or any object that implements a split_text method) to attach to doc (used for splitting out pages in an HTML document). By default, None.

Methods

parse(doc)

Extract date (year, month, day) from doc

Attributes

SYSTEM_MESSAGE

System message for date extraction LLM calls

SYSTEM_MESSAGE = 'You are a legal scholar that reads ordinance text and extracts a single date. The date you report is the latest year the ordinance was enacted or amended or became effective. If no such date is available return null.Return your answer in JSON format like this: {"explanation": TEXT, "year": YY, "month": MM, "day": DD}Where explanation contains a short summary/explanation of the date information you found, including the exact text the date is based on.'#

System message for date extraction LLM calls

async parse(doc)[source]#

Extract date (year, month, day) from doc

The full document text is read in a single LLM call. The document’s source URL, if any, is passed along as a hint, but the document text is the source of truth.

Parameters:

doc (elm.web.document.BaseDocument) – Document to parse.

Returns:

tuple – 3-tuple of (year, month, day). Any element that cannot be determined is None.