Ontology KB files: declarative content held as plain text on the classpath rather than as code.
A KB file is a list of ordinary vaelii sentences — one s-expression each, with
;; line comments and blank lines allowed — named for the context its sentences
assert into, and grouped term-centrically: every sentence about a vocabulary
term sits together, and the terms run in natural sort order. A rule is just a
sentence carrying an implies / set/*Rule / exceptWhen wrapper.
The format itself — reader and writer both — is vaelii.impl.io.text, which is
where its two non-sentence spellings live ((set/monotonic S) and (set/inert S))
and what vaelii.core/export-text! writes. What is here is the classpath side: the
shallow tree under resources/kb/ and how a layer's files are discovered in it.
The files live under resources/kb/, in two layers:
kb/upper/<domain>.txt the upper ontology, every file loaded into CxUniverse
(see vaelii.host.core-context)
kb/middle/<C>.txt theory contexts, each seeing CxUniverse
An upper file is named for its domain (core.txt is the vocabulary); a middle file's
name is its context. Only the layer a caller names is discovered, so a sibling
directory under kb/ that names no layer here is not loaded: kb/koinii/ is one, an
application's own context files, which that application loads for itself. What stays
in code (vaelii.host.core-context, vaelii.host.starter) is the order the layers
load in and the one computed batch. Sentences read with clojure.edn, so a KB file
is data and can never run code.
Ontology KB files: declarative content held as **plain text on the classpath**
rather than as code.
A KB file is a list of ordinary vaelii sentences — one s-expression each, with
`;;` line comments and blank lines allowed — named for the context its sentences
assert into, and grouped **term-centrically**: every sentence about a vocabulary
term sits together, and the terms run in natural sort order. A rule is just a
sentence carrying an `implies` / `set/*Rule` / `exceptWhen` wrapper.
**The format itself — reader and writer both — is `vaelii.impl.io.text`**, which is
where its two non-sentence spellings live (`(set/monotonic S)` and `(set/inert S)`)
and what `vaelii.core/export-text!` writes. What is here is the *classpath* side: the
shallow tree under `resources/kb/` and how a layer's files are discovered in it.
The files live under `resources/kb/`, in two layers:
kb/upper/<domain>.txt the upper ontology, every file loaded into CxUniverse
(see vaelii.host.core-context)
kb/middle/<C>.txt theory contexts, each seeing CxUniverse
An upper file is named for its domain (`core.txt` is the vocabulary); a middle file's
*name* is its context. Only the layer a caller names is discovered, so a sibling
directory under `kb/` that names no layer here is not loaded: `kb/koinii/` is one, an
application's own context files, which that application loads for itself. What stays
in **code** (vaelii.host.core-context, vaelii.host.starter) is the *order* the layers
load in and the one computed batch. Sentences read with `clojure.edn`, so a KB file
is data and can never run code.The classpath path of the file every KB carries: layer discovery anchors on it when a jar records no directory entry for the layer.
The classpath path of the file every KB carries: layer discovery anchors on it when a jar records no directory entry for the layer.
(layer-contexts dir)The context symbols whose KB files live in the layer sub-directory dir ("middle"),
sorted for determinism. Discovered from the classpath, so dropping a new
Cx<Name>.txt in kb/<dir>/ loads it with no code change — every context is loaded
on kb start by default, from a filesystem tree and from a packaged jar alike
(layer-files).
The context symbols whose KB files live in the layer sub-directory `dir` ("middle"),
sorted for determinism. Discovered from the classpath, so dropping a new
`Cx<Name>.txt` in `kb/<dir>/` loads it with no code change — every context is loaded
on kb start by default, from a filesystem tree and from a packaged jar alike
(`layer-files`).(layer-files dir)The .txt file names in layer sub-directory dir, sorted, or nil when it holds none.
They are read off whichever classpath shape holds them: a filesystem tree (repl / lein /
test) is listed as a directory, and a packaged jar is listed by its own entries —
anchored on anchor when the jar carries no directory entry for kb/<dir> to resolve.
Any other protocol is refused rather than answered nil: nil here starts a KB with a
layer silently absent, the exact failure read-sentences exists to refuse one file at a
time.
The `.txt` file names in layer sub-directory `dir`, sorted, or nil when it holds none. They are read off whichever classpath shape holds them: a filesystem tree (repl / lein / test) is listed as a directory, and a packaged jar is listed by its own entries — anchored on `anchor` when the jar carries no directory entry for `kb/<dir>` to resolve. Any other protocol is refused rather than answered nil: nil here starts a KB with a layer silently absent, the exact failure `read-sentences` exists to refuse one file at a time.
(load-context kb context)(load-context kb context dir)Assert every sentence of the KB file for context into that context, through
load-sentences — so the file's term order is not also asked to be a dependency
order. dir names the layer sub-directory, nil for the kb/ root. Returns kb.
Assert every sentence of the KB file for `context` into that context, through `load-sentences` — so the file's term order is not also asked to be a dependency order. `dir` names the layer sub-directory, nil for the `kb/` root. Returns kb.
(load-sentences kb sentences context)Assert sentences into context, order-insensitively — text/load-entries!,
which is the loader for this format wherever it is read from (vaelii.core/load-text!
reads a file tree through the same one). Returns kb.
A KB file's order is its terms', not its dependencies', so a sentence refused
because content further down the list has not arrived yet is retried rather than
fatal; text/load-entries! says why, and what a clean list pays.
Assert `sentences` into `context`, **order-insensitively** — `text/load-entries!`, which is the loader for this format wherever it is read from (`vaelii.core/load-text!` reads a file tree through the same one). Returns kb. A KB file's order is its *terms'*, not its dependencies', so a sentence refused because content further down the list has not arrived yet is retried rather than fatal; `text/load-entries!` says why, and what a clean list pays.
(read-sentences file)(read-sentences file dir)Read every sentence from KB file file — the context a middle file is named for, or
an upper file's name — in file order. dir names the layer sub-directory ("upper"
/ "middle"), nil for a file at the kb/ root. Throws if the resource is missing: a
silently empty ontology is worse than a failure to start.
Read every sentence from KB file `file` — the context a middle file is named for, or
an upper file's name — in file order. `dir` names the layer sub-directory ("upper"
/ "middle"), nil for a file at the `kb/` root. Throws if the resource is missing: a
silently empty ontology is worse than a failure to start.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |