aeat.application.corpus_search._citation_lookup module

Structured exact-citation lookup over the registry legal catalogue.

Exact citations (“art. 27.2 LGT”, ley-58-2003:art-27.2) do not go through the FTS index: the wheel already ships typed citation data (the registry legal_refs with their corpus_ref and BOE permalinks), so this is a direct structured key lookup, not a parallel citation parser. The registry legal catalogue is the single citation authority (aeat-registry-authority-flow); this module reuses it and adds the one thing the product lacked at runtime: resolving a citation id to the verbatim authoritative text its corpus_ref points at.

The verbatim text is read from the bundled *.extracted.json sidecar (the clean, structured extraction the corpus ships) rather than the raw HTML, and sliced to the unit the citation’s anchor names when the source file carries multiple units.

See also

CitationResolution

Typed result carrying catalogue metadata and verbatim text.

search_corpus()

Exact citation ids short-circuit through this lookup before ranking.

_read_corpus_resource()

aeat://corpus resource reader that accepts citation ids and retrieval corpus_ref values.

class CitationLookup(legal, *, source_root)[source]

Bases: object

Resolve a registry citation id to metadata plus verbatim text.

The lookup is built over the reviewed legal catalogue and the corpus source root (the bundled _data tree the catalogue’s corpus_ref values are relative to).

Parameters:
property citation_ids: tuple[str, ...]

Return every resolvable citation id, sorted.

resolve(citation_id)[source]

Resolve citation_id to a CitationResolution.

Parameters:

citation_id (str) – A registry legal_refs id, e.g. ley-58-2003:art-27.2.

Return type:

CitationResolution

Returns:

The citation’s catalogue metadata plus the verbatim authoritative text its corpus_ref points at.

Raises:

CorpusSearchInputError – If the id is unknown to the catalogue or its backing corpus text cannot be read.

resolve_corpus_text(ref)[source]

Resolve a citation id OR a corpus_ref (path#anchor) to verbatim text.

The aeat://corpus/{ref} resource accepts either form: a retrieval hit’s corpus_ref or a bare citation id. A known citation id routes through resolve(); otherwise ref is read as a corpus path and anchor.

Raises:

CorpusSearchInputError – If ref resolves to no readable text or escapes the corpus root.

Return type:

str

Parameters:

ref (str)

bundled_citation_lookup()[source]

Return a CitationLookup over the bundled registry catalogue.

Return type:

CitationLookup