compass.validation.location.CountyNameValidator#

class CountyNameValidator(structured_llm_caller)[source]#

Bases: LocationValidator

Validator that checks whether text applies to a given county

Parameters:

structured_llm_caller (StructuredLLMCaller) – StructuredLLMCaller instance. Used for structured validation queries.

Methods

check(content, **fmt_kwargs)

Check if the content passes the validation

Attributes

META_SCORE_KEY

SYSTEM_MESSAGE

LLM system message describing validation task

SYSTEM_MESSAGE = 'You extract structured data from legal text. Return your answer in JSON format with exactly three keys: `"wrong_county"`, `"wrong_state"`, and `"explanation"`.\n\n1. **`"wrong_county"` (boolean):**\n- Set this to `true` **only if** the text **explicitly states** that it does **not** apply to {county} County.\n- Set this to `false` if the text applies to {county} County **or** if there is **not enough information** to determine the county.\n- Do **not** infer this based on any mention of other U.S. states, cities, or townships.\n\n2. **`"wrong_state"` (boolean):**\n- Set this to `true` **only if** the text **explicitly states** that it does **not** apply to a jurisdiction in {state}.\n- Set this to `false` if the text applies to a jurisdiction in {state} **or** if there is **not enough information** to determine the state.\n- Do **not** infer this based on any mention of other U.S. counties, cities, or townships.\n\n3. **`"explanation"` (string):**\n- If either `"wrong_county"` or `"wrong_state"` is `true`, provide a short explanation **citing the specific text** that led to this conclusion.\n- If **both** are `false`, explain that there was not enough information to determine otherwise.\n\n### **Example Output:**\n\n#### Correct Cases:\n\n**Case 1 (Not Enough Information - Default to `False`)**\nInput text: `"This ordinance applies to wind energy regulations in the county."`\n```json\n{{\n  "wrong_county": false,\n  "wrong_state": false,\n  "explanation": "The legal text does not provide enough information to determine whether it applies to {county} County or {state}."\n}}\n\n**Case 2 (Explicit Wrong County and State)**\nInput text: `"This ordinance applies to {not_county} County, {not_state}."`\n```json\n{{\n  "wrong_county": true,\n  "wrong_state": true,\n  "explanation": "The legal text explicitly states that it applies to {not_county} County, {not_state}, which is not {county} County or in {state}."\n}}\n\n**Case 3 (Explicit Wrong State)**\nInput text: `"This law applies to counties in {not_state}."`\n```json\n{{\n  "wrong_county": false,\n  "wrong_state": true,\n  "explanation": "The legal text explicitly states it applies to counties in {not_state}, which is not in {state}."\n}}\n\n**Case 4 (Explicit Wrong County)**\nInput text: `"This law applies to {not_county} County."`\n```json\n{{\n  "wrong_county": true,\n  "wrong_state": false,\n  "explanation": "The legal text explicitly states it applies to {not_county} County, which is not in {county} County."\n}}\n'#

LLM system message describing validation task

async check(content, **fmt_kwargs)#

Check if the content passes the validation

The exact validation is outlined in the class SYSTEM_MESSAGE.

Parameters:
  • content (str) – Document content to validate.

  • **fmt_kwargs – Keyword arguments to be passed to SYSTEM_MESSAGE.format().

Returns:

boolTrue if the content passes the validation check, False otherwise.