elm.ords.extraction.parse.StructuredOrdinanceParser
- class StructuredOrdinanceParser(llm_service, usage_tracker=None, **kwargs)[source]
Bases:
BaseLLMCaller
LLM ordinance document structured data scraping utility
- Purpose:
Extract structured ordinance data from text.
- Responsibilities:
Extract ordinance values into structured format by executing a decision-tree-based chain-of-thought prompt on the text for each value to be extracted.
- Key Relationships:
Uses a
StructuredLLMCaller
for LLM queries and multipleAsyncDecisionTree
instances to guide the extraction of individual values.
- Parameters:
llm_service (elm.ords.services.base.Service) – LLM service used for queries.
usage_tracker (elm.ords.services.usage.UsageTracker, optional) – Optional tracker instance to monitor token usage during LLM calls. By default,
None
.**kwargs – Keyword arguments to be passed to the underlying service processing function (i.e. llm_service.call(**kwargs)). Should not contain the following keys:
usage_tracker
usage_sub_label
messages
These arguments are provided by this caller object.
Methods
parse
(text)Parse text and extract structure ordinance data.
- async parse(text)[source]
Parse text and extract structure ordinance data.
- Parameters:
text (str) – Ordinance text which may or may not contain setbacks for one or more features (property lines, structure, roads, etc.). Text can also contain other supported regulations (noise, shadow-flicker, etc,) which will be extracted as well.
- Returns:
pd.DataFrame – DataFrame containing parsed-out ordinance values.