Liking cljdoc? Tell your friends :D

vaelii.impl.naming

KB naming invariants, as predicates over symbols — and the walk that applies them to every literal of a sentence rather than to its outermost functor alone.

predicate camelCase, lowercase-initial, no underscore parentOf, genl, argIsa individual CapitalCamelCase Fido, Tom type snake_case, lowercase, unary predicate dog, physical_object context CapitalCamelCase ending in Context UniverseContext, CoreContext

Single lowercase words (dog, genl, parentOf) satisfy both predicate? and type-symbol?; role is disambiguated by position and arity, not the symbol alone. A functor carrying an underscore is a type name and nothing else, and types are used as unary predicates — (dog Fido), not (isa Fido Dog) — so it is legal at arity 1 and nowhere else. (lives_in penguin cold_place) is a type name doing a relation's job; admitting it fragments the vocabulary into one-off predicates (lives_in_antarctica, capable_of_swimming) that can never join a rule or match another sentence.

How hard these are enforced is the KB's to say, not this namespace's: open-kb's :naming selects :strict / :warn / :off (policies, below) and assert reads it. The predicates themselves do not move — :off stores a name nothing can classify, not one classified differently.

problems checks the functor of every literal a sentence contains — a rule's antecedents, its consequent, an exceptWhen query's conjuncts, a not body, an ist-directed sentence, a negation-as-failure query — not only the outermost one. A rule consequent is exactly where generated content lands, and the outermost functor there is implies.

KB naming invariants, as predicates over symbols — and the walk that applies them to
every **literal** of a sentence rather than to its outermost functor alone.

  predicate    camelCase, lowercase-initial, no underscore   parentOf, genl, argIsa
  individual   CapitalCamelCase                               Fido, Tom
  type         snake_case, lowercase, unary predicate         dog, physical_object
  context      CapitalCamelCase ending in Context             UniverseContext, CoreContext

Single lowercase words (dog, genl, parentOf) satisfy both `predicate?` and
`type-symbol?`; role is disambiguated by position and arity, not the symbol alone.
A functor carrying an **underscore** is a type name and nothing else, and types are
used as *unary* predicates — `(dog Fido)`, not `(isa Fido Dog)` — so it is legal at
arity 1 and nowhere else.  `(lives_in penguin cold_place)` is a type name doing a
relation's job; admitting it fragments the vocabulary into one-off predicates
(`lives_in_antarctica`, `capable_of_swimming`) that can never join a rule or match
another sentence.

How hard these are enforced is the **KB's** to say, not this namespace's: `open-kb`'s
`:naming` selects `:strict` / `:warn` / `:off` (`policies`, below) and `assert` reads
it.  The predicates themselves do not move — `:off` stores a name nothing can classify,
not one classified differently.

`problems` checks the functor of every literal a sentence contains — a rule's
antecedents, its consequent, an `exceptWhen` query's conjuncts, a `not` body, an
`ist`-directed sentence, a negation-as-failure query — not only the outermost one.
A rule consequent is exactly where generated content lands, and the outermost
functor there is `implies`.
raw docstring

argsclj

(args sentence)

arityclj

(arity sentence)

blocking-problemsclj

(blocking-problems policy sentence context)

The naming violations that stop something under policy — the messages, or nil. Empty under :warn and :off by construction, so a caller that has to yield a value rather than throw (special/definitional-violation, the assert dry run) asks this and needs no policy branch of its own.

The naming violations that **stop** something under `policy` — the messages, or nil.
Empty under `:warn` and `:off` by construction, so a caller that has to yield a value
rather than throw (`special/definitional-violation`, the `assert` dry run) asks this
and needs no policy branch of its own.
raw docstring

check!clj

(check! policy sentence context)

Enforce policy on sentence in context: throw :naming under :strict, log under :warn, do nothing under :off. The one place the three differ, so no caller spells the throw out and none can drift from another.

Enforce `policy` on `sentence` in `context`: throw `:naming` under `:strict`, log
under `:warn`, do nothing under `:off`.  The one place the three differ, so no caller
spells the throw out and none can drift from another.
raw docstring

context?clj

(context? x)

empty-tallyclj

A fresh tally accumulator: records seen, records with at least one violation, and the per-class breakdown. Counts records rather than violations — one sentence can break three conventions, and what an operator is deciding is what fraction of the corpus is re-assertable.

A fresh `tally` accumulator: records seen, records with at least one violation, and
the per-class breakdown.  Counts records rather than violations — one sentence can
break three conventions, and what an operator is deciding is what fraction of the
corpus is re-assertable.
raw docstring

functorclj

(functor sentence)

individual?clj

(individual? x)

literalsclj

(literals sentence)
(literals role form)

The [role literal] pairs of sentence as written — every position at which it applies a predicate to arguments, tagged with the frame that position sits in (:sentence / :antecedent / :consequent / :exception).

Frames are descended through, arguments are not, so this is exactly the set of functors an author named.

The `[role literal]` pairs of `sentence` as written — every position at which it
applies a predicate to arguments, tagged with the frame that position sits in
(`:sentence` / `:antecedent` / `:consequent` / `:exception`).

Frames are descended through, arguments are not, so this is exactly the set of
functors an author named.
raw docstring

messageclj

(message {:keys [class role symbol literal]})

One problems* map rendered as the line a rejection carries. Every message names the offending symbol, the frame it sits in and the spelling to write instead: whoever reads it is mid-repair, and a violation reported without its fix is a second lookup.

One `problems*` map rendered as the line a rejection carries.  Every message names
the offending symbol, the frame it sits in and the spelling to write instead: whoever
reads it is mid-repair, and a violation reported without its fix is a second lookup.
raw docstring

policiesclj

What a KB does with a naming violation, and the one line each is for.

A bulk path is not on this list because it does not consult it: a corpus import builds records directly and never asks (docs/naming.md, "The two doors"). What it does instead is report — an operator learns the refused fraction at load time, from a count rather than from a failed experiment a year later.

What a KB does with a naming violation, and the one line each is for.

A bulk path is not on this list because it does not consult it: a corpus import builds
records directly and never asks (`docs/naming.md`, "The two doors").  What it does
instead is *report* — an operator learns the refused fraction at load time, from a
count rather than from a failed experiment a year later.
raw docstring

predicate?clj

(predicate? x)

problem-classesclj

What a naming violation is, as a keyword, with the human line under it. A rejection reads as prose, but a caller that counts them needs to group without parsing English — an operator auditing a corpus wants five numbers, not eleven million sentences — so the class is the datum and the message is rendered from it.

What a naming violation *is*, as a keyword, with the human line under it.  A rejection
reads as prose, but a caller that counts them needs to group without parsing English —
an operator auditing a corpus wants five numbers, not eleven million sentences — so the
class is the datum and the message is rendered from it.
raw docstring

problemsclj

(problems sentence context)

Checkable naming violations for a sentence in a context (seq of strings): the context's own name, then every literal's functor (outermost frame first), then every literal's atomic symbol arguments, then any ist context slot, then the dotted rest marker where it cannot appear.

This is a check on the shape of a name, not on whether the name is worth having. A unary snake_case functor is a well-formed type name, so (implies (penguin ?x) (has_black_and_white_feathers ?x)) passes here, and so would capable_of_swimming or thermoregulates_via_blubber_and_feathers — each is exactly what the invariants say a type looks like. Nothing about a symbol distinguishes a type the ontology wants from a one-off coined for a single sentence, so nothing here can refuse the second: judging that needs the KB's existing vocabulary, which is a separate question asked elsewhere. Read this as a guard against misnamed content, never as a guard against vocabulary fragmentation.

Checkable naming violations for a sentence in a context (seq of strings): the
context's own name, then every literal's functor (outermost frame first), then every
literal's atomic symbol arguments, then any `ist` context slot, then the dotted rest
marker where it cannot appear.

**This is a check on the shape of a name, not on whether the name is worth having.**
A *unary* snake_case functor is a well-formed type name, so
`(implies (penguin ?x) (has_black_and_white_feathers ?x))` passes here, and so would
`capable_of_swimming` or `thermoregulates_via_blubber_and_feathers` — each is exactly
what the invariants say a type looks like.  Nothing about a symbol distinguishes a
type the ontology wants from a one-off coined for a single sentence, so nothing here
can refuse the second: judging that needs the KB's existing vocabulary, which is a
separate question asked elsewhere.  Read this as a guard against *misnamed* content,
never as a guard against vocabulary fragmentation.
raw docstring

problems*clj

(problems* sentence context)

Checkable naming violations for a sentence in a context, as data: a vector of {:class :role :symbol :literal} maps in the order problems reports them. :class is one of problem-classes, :role the frame the offending literal sits in, :symbol the name that broke the convention, and message renders the line.

Data rather than prose because the two callers want different halves of it. assert wants the sentence it refused spelled out; an audit over a whole corpus wants to group — how many violations, of which class, over how many distinct spellings — and a message that embeds the literal is unique per record, so counting them counts records. Rendering is therefore separate and paid only where a message is read.

Checkable naming violations for a sentence in a context, as **data**: a vector of
`{:class :role :symbol :literal}` maps in the order `problems` reports them.  `:class`
is one of `problem-classes`, `:role` the frame the offending literal sits in, `:symbol`
the name that broke the convention, and `message` renders the line.

Data rather than prose because the two callers want different halves of it.  `assert`
wants the sentence it refused spelled out; an audit over a whole corpus wants to
*group* — how many violations, of which class, over how many distinct spellings — and
a message that embeds the literal is unique per record, so counting them counts
records.  Rendering is therefore separate and paid only where a message is read.
raw docstring

tallyclj

(tally t sentence context)

Fold one sentence's violations into t. Counts and classes only, never spellings: a corpus large enough to need a bulk path has a vocabulary large enough that holding its distinct offending names would cost more than the load (vaelii.bench.survey's naming audit is where that question is asked).

Fold one sentence's violations into `t`.  Counts and classes only, never spellings: a
corpus large enough to need a bulk path has a vocabulary large enough that holding its
distinct offending names would cost more than the load
(`vaelii.bench.survey`'s `naming` audit is where that question is asked).
raw docstring

tally-lineclj

(tally-line t)

The one line a load prints about t, or nil when the front door agrees with the corpus — which is the common case and deserves no output at all.

The one line a load prints about `t`, or nil when the front door agrees with the
corpus — which is the common case and deserves no output at all.
raw docstring

type-symbol?clj

(type-symbol? x)

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close