Skip to main content
An optional entities: section of ladygraph.yaml names things a deployment’s documents contain and explains them: document codes, form codes, decision numbers and abbreviations. It sits next to sources: and is read by sources/entities.py (load_entities, EntityEngine, Lexicon). A kind is data, so a new kind is a new entry in the config.
Keys fold case, accents and separators the same way keyword matching does, so REF.AB.010 and RÉF.AB.010 are one entry. The metadata resolver reads Document.metadata[code], so a SQL source supplies it with map.metadata. An answer is always a short title or expansion with a pointer (address, span and fingerprint). It is never copied source text. The full example is docs/entity_kinds.example.yaml in the repository. To inspect the entries:

Entries as concepts

With a concepts: section, LexiconExtractor (extractors/lexicon.py) wraps any extractor. To each document’s own contribution it adds a concept for every code the document mentions that deserves one, and REFERS_TO links from the document’s concepts to those codes. A code’s concept has:
  • A title equal to the code as first written. The title makes the id, so it must not change when a meaning is reworded.
  • A description of one sentence with the meaning and the code (describe_resolved, or describe_unresolved when no document spells it out).
  • The code as a user word, stamped human:<actor>, because the person who wrote the pattern defined it.
  • Evidence: the written meaning first, then up to evidence_per_document other mentions.
One code is one concept. Every document’s contribution carries only its own evidence, and the store merges them. Contexts are one top-level context per kind, named by the kind’s label.

Which entries get a concept

  • Not a hub, meaning not in more than max_share of passages.
  • When no meaning was found, the code must appear in at least min_passages_unresolved passages, and must not be an all-caps word that is also written normally lowercase_words times.
  • A kind can opt out with concept: false.
A document concept gets REFERS_TO a code its passage mentions in either of two cases:
  • The code is in the concept’s own title or description.
  • The concept is the heading of its passage (its evidence starts in the first heading_chars), and the passage mentions at most max_codes_in_passage codes.
There are at most max_links links per concept. A code with no meaning and no link in a document gets no concept there. Declare the relation in the ontology with origin: entities, which also keeps it from being offered to the LLM:
The defaults were tuned on one corpus, so check them on yours. The numbers are in the example config. A known limit: a merged concept’s first evidence is the first unit’s, not necessarily the one that holds the meaning. A question about a code can therefore find the right concept and show another mention. The extractor puts the meaning first inside its own contribution, but guaranteeing it across units is for the store.