Skip to main content

Corpus

Struct Corpus 

Source
pub struct Corpus { /* private fields */ }

Implementations§

Source§

impl Corpus

Source

pub fn from_projector(p: Box<dyn Projector>) -> Result<Corpus>

Build the index + forward store by draining any projector’s Situation stream.

Source

pub fn from_csv(path: &Path) -> Result<Corpus>

Source

pub fn from_json(path: &Path) -> Result<Corpus>

Source

pub fn from_jsonl(path: &Path, max_lines: Option<usize>) -> Result<Corpus>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

pub fn index(&self) -> &InfonIndex<RoarPostings>

The underlying inverted index, for callers that need the lower-level set algebra or the topology programs directly.

Source

pub fn query(&self, ikl: &str, limit: usize) -> QueryOut

Source

pub fn facet_tokens(&self, facet: &str, limit: usize) -> Vec<(String, usize)>

Top tokens under a facet (for agent vocabulary discovery).

Source

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.

Source

pub fn has_token(&self, token: &str) -> bool

True if token (a facet/value) exists in the index.

Source

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).

Source

pub fn signed_mass(&self, token: &str) -> f64

Net signed infon mass for a token over the whole corpus.

Source

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).

Source

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.

Source

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.

Source

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).

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).

Source

pub fn breakdown(&self, anchor: &str, facet: &str, k: usize) -> Value

Source

pub fn crosstab( &self, anchor: &str, facet_a: &str, facet_b: &str, k: usize, ) -> Value

Source

pub fn rank(&self, facet: &str, k: usize) -> Value

Source

pub fn cooccurs(&self, token: &str, k: usize) -> Value

Source

pub fn s_path(&self, a: &str, b: &str, s: usize) -> Value

Source

pub fn s_clusters(&self, s: usize, k: usize) -> Value

Source

pub fn narrow(&self, scope: &[String], filters: &[String]) -> Value

Source

pub fn stats(&self) -> Stats

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more