pub struct Corpus { /* private fields */ }Implementations§
Source§impl Corpus
impl Corpus
Sourcepub fn from_projector(p: Box<dyn Projector>) -> Result<Corpus>
pub fn from_projector(p: Box<dyn Projector>) -> Result<Corpus>
Build the index + forward store by draining any projector’s Situation stream.
pub fn from_csv(path: &Path) -> Result<Corpus>
pub fn from_json(path: &Path) -> Result<Corpus>
pub fn from_jsonl(path: &Path, max_lines: Option<usize>) -> Result<Corpus>
Sourcepub fn from_folder(dir: &Path) -> Result<(Corpus, FolderReport)>
pub fn from_folder(dir: &Path) -> Result<(Corpus, FolderReport)>
Ingest a whole folder into ONE corpus — the “ask over a folder” path. Each file is auto-routed
to a projector by extension (csv/tsv, json/ndjson/jsonl, and — with the onnx feature + models
present — txt/md). Every situation is tagged with a src/<file> token and its file is shown, so
the agent can slice by source. Unsupported files are skipped and counted.
Sourcepub fn from_document(path: &Path) -> Result<Corpus>
pub fn from_document(path: &Path) -> Result<Corpus>
Single document (pdf/docx/pptx/html/md/txt) → extract text → text-projected corpus. Uses the env/default text engine; errors if the models or extractable text are absent.
Sourcepub fn from_text(
path: &Path,
ml_bundle: &Path,
splade_dir: Option<&Path>,
) -> Result<Corpus, Box<dyn Error + Send + Sync>>
pub fn from_text( path: &Path, ml_bundle: &Path, splade_dir: Option<&Path>, ) -> Result<Corpus, Box<dyn Error + Send + Sync>>
Native text projection (SPO tagger + optional English SPLADE) → queryable corpus.
Sourcepub fn new_incremental(
source: impl Into<String>,
columns: Vec<String>,
kind: CorpusKind,
) -> Corpus
pub fn new_incremental( source: impl Into<String>, columns: Vec<String>, kind: CorpusKind, ) -> Corpus
An empty corpus to grow incrementally (realtime/hot-model ingest): add_situation appends as
documents are projected, and the query/agent layer sees each addition immediately.
Sourcepub fn set_gazetteer_overlay(&mut self, path: impl Into<PathBuf>)
pub fn set_gazetteer_overlay(&mut self, path: impl Into<PathBuf>)
Point the query-side gazetteer at a growing-gazetteer overlay file (entities learned at ingest). Must be called before the first query so the lazily-loaded gazetteer picks it up.
Sourcepub fn add_situation(
&mut self,
tokens: Vec<String>,
display: Vec<String>,
) -> u32
pub fn add_situation( &mut self, tokens: Vec<String>, display: Vec<String>, ) -> u32
Append one projected situation. Invalidates the high-DF noise cache (the corpus size changed), so registration recomputes on the next analytics call. Returns the new sid.
Sourcepub fn add_situation_num(
&mut self,
tokens: Vec<String>,
display: Vec<String>,
numbers: Vec<(String, f64)>,
) -> u32
pub fn add_situation_num( &mut self, tokens: Vec<String>, display: Vec<String>, numbers: Vec<(String, f64)>, ) -> u32
Append one situation with numeric fields (realtime ingest of CSV/text carrying quantities).
Sourcepub fn add_situation_polar(
&mut self,
tokens: Vec<String>,
display: Vec<String>,
numbers: Vec<(String, f64)>,
beliefs: Vec<(String, f32)>,
) -> u32
pub fn add_situation_polar( &mut self, tokens: Vec<String>, display: Vec<String>, numbers: Vec<(String, f64)>, beliefs: Vec<(String, f32)>, ) -> u32
Append a situation carrying infon polarity for some of its tokens (paper §1.2, §4): each
(token, i) records that assertion’s belief level, so Dempster-Shafer Bel/Pl and signed mass
are computable over the bitmap. Tokens absent from beliefs default to +1 (asserted).
Sourcepub fn index(&self) -> &InfonIndex<RoarPostings>
pub fn index(&self) -> &InfonIndex<RoarPostings>
The underlying inverted index, for callers that need the lower-level set algebra or the topology programs directly.
pub fn query(&self, ikl: &str, limit: usize) -> QueryOut
Sourcepub fn facet_tokens(&self, facet: &str, limit: usize) -> Vec<(String, usize)>
pub fn facet_tokens(&self, facet: &str, limit: usize) -> Vec<(String, usize)>
Top tokens under a facet (for agent vocabulary discovery).
Sourcepub fn facet_names(&self) -> Vec<String>
pub fn facet_names(&self) -> Vec<String>
Distinct facet names (token prefixes) present in the corpus — the real schema, for validating DSL/tool arguments against what was actually extracted.
Sourcepub fn has_token(&self, token: &str) -> bool
pub fn has_token(&self, token: &str) -> bool
True if token (a facet/value) exists in the index.
Sourcepub fn belief_interval(&self, token: &str) -> (f64, f64)
pub fn belief_interval(&self, token: &str) -> (f64, f64)
Dempster-Shafer belief interval [Bel, Pl] for a token over the whole corpus (paper §4.1).
Sourcepub fn signed_mass(&self, token: &str) -> f64
pub fn signed_mass(&self, token: &str) -> f64
Net signed infon mass for a token over the whole corpus.
Sourcepub fn linter(&self) -> Linter
pub fn linter(&self) -> Linter
A linter over this corpus’s vocabulary — validates IKL atoms, suggests corrections, repairs syntax (paper §2, the compile-time boundary).
Sourcepub fn top_token_leaves(&self, limit: usize) -> Vec<String>
pub fn top_token_leaves(&self, limit: usize) -> Vec<String>
Distinct leaf values of the most-supported tokens — candidate terms for ontology discovery over the corpus’s own vocabulary.
Sourcepub fn noise_tokens(&self) -> &HashSet<String>
pub fn noise_tokens(&self) -> &HashSet<String>
REGISTRATION — non-discriminative tokens present in > ~12% of situations: the coarse fragments
(developers, reference…) that co-occur with everything and drown the analytics. Concept facets
only; contextual facets (time/geo/qty/dur) and the specific gazetteer/entity values survive.
Ported from query.ts registration() (71e1714). Computed once, then cached.
Sourcepub fn search_ranked(
&self,
tokens: &[String],
limit: usize,
) -> Vec<(u32, usize, Vec<String>)>
pub fn search_ranked( &self, tokens: &[String], limit: usize, ) -> Vec<(u32, usize, Vec<String>)>
Retrieve situations matching ANY of tokens, ranked by coverage (how many of the query tokens
each situation contains) then sid. This makes free-text search return the most-relevant passages
first instead of document order. Returns (sid, coverage, cells).
Sourcepub fn entity_link(&self, question: &str) -> Vec<String>
pub fn entity_link(&self, question: &str) -> Vec<String>
Entity-linking: resolve a question’s mentions (acronyms, content words, prefixes, bigrams) plus
any gazetteer surfaces to the store’s PRECISE existing tokens — the tokens docs are actually
indexed under, which the coarse SPLADE projection of a short question misses. Pure set-algebra
linking (no lexical text search). Noise tokens are excluded. Ported from query.ts (17d6490).
pub fn breakdown(&self, anchor: &str, facet: &str, k: usize) -> Value
pub fn crosstab( &self, anchor: &str, facet_a: &str, facet_b: &str, k: usize, ) -> Value
pub fn rank(&self, facet: &str, k: usize) -> Value
pub fn cooccurs(&self, token: &str, k: usize) -> Value
pub fn s_path(&self, a: &str, b: &str, s: usize) -> Value
pub fn s_clusters(&self, s: usize, k: usize) -> Value
pub fn narrow(&self, scope: &[String], filters: &[String]) -> Value
pub fn stats(&self) -> Stats
Auto Trait Implementations§
impl !Freeze for Corpus
impl RefUnwindSafe for Corpus
impl Send for Corpus
impl Sync for Corpus
impl Unpin for Corpus
impl UnsafeUnpin for Corpus
impl UnwindSafe for Corpus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more