Skip to main content

LookupTable

Struct LookupTable 

Source
pub struct LookupTable {
    pub id: String,
    pub info: LookupInfo,
    /* private fields */
}
Expand description

One mounted lookup record.

Fields§

§id: String§info: LookupInfo

Implementations§

Source§

impl LookupTable

Source

pub fn record<'a>(model: &'a CmfModel, id: &str) -> Option<&'a SkillRecord>

The record id when it is a lookup record.

Source

pub fn is_lookup(model: &CmfModel, id: &str) -> bool

Source

pub fn lookup_ids(model: &CmfModel) -> Vec<String>

Ids of every lookup record of the file, in header order.

Source

pub fn open(model: &Arc<CmfModel>, id: &str) -> Result<Self, String>

Read the record’s four tensors (the file’s open() validated their values; only the shapes are re-checked here). The blob stays in the mapping.

Source

pub fn keys(&self) -> usize

Source

pub fn recovered_keys(&self) -> usize

Key texts recovered from the cards at open (the stem index is built from these; a key no card spells has no stem).

Source

pub fn stems(&self) -> &StemIndex

The stem index (stems, ambiguous stems dropped).

Source

pub fn entries(&self) -> usize

Source

pub fn langs(&self) -> &[String]

Source

pub fn fields(&self) -> &[String]

Source

pub fn blob(&self) -> &[u8] ⓘ

The UTF-8 card blob (zero-copy from the file’s mapping).

Source

pub fn find_hash(&self, h: u64) -> Option<u32>

The entry of key hash h (binary search over the sorted hashes).

Source

pub fn find_stem_hash(&self, h: u64) -> Option<u32>

The entry of stem hash h (StemIndex::find).

Source

pub fn slot_text(&self, entry: u32, lang: usize) -> Option<&str>

The raw slot text of entry in language index lang.

Source

pub fn card(&self, entry: u32, lang: usize) -> Result<Card, String>

The parsed card of entry in language index lang.

Source

pub fn find_key(&self, message: &str) -> Option<KeyHit>

extract_key_with against this table (the exact index, then the stem index): the strongest key of the message, else the first weak one — the rule every path shares (the router’s pick, key_first, the conversation memory).

Source

pub fn find_strong_key(&self, message: &str) -> Option<KeyHit>

extract_strong_key_with against this table: the key the key_first policy acts on (is_strong_key).

Source

pub fn policy(&self) -> LookupPolicy

The record’s routing policy (LookupPolicy::of: a value this reader does not know is router_and_key).

Source

pub fn answer(&self, message: &str) -> Result<Option<LookupAnswer>, String>

The table’s answer to message: the key, the language by script (an empty slot — the entry does not carry that language — falls back to the first language whose card has text), the field by keywords — its text when the card has it, else the whole card. None = no key in the message, or a key whose card is empty in every language (Self::find_answer tells the two apart).

Source

pub fn find_answer(&self, message: &str) -> Result<Found, String>

Self::answer with the miss reason: no key in the message, or a key found but no card text in any language.

Source

pub fn find_answer_turns(&self, turns: &[&str]) -> Result<Found, String>

Self::find_answer with conversation memory: turns are the user messages, the LAST one first (the message the request was routed on), then the earlier ones back in time (the caller passes at most MEMORY_TURNS). The key comes from the first turn that holds one (KeyHit::turn = how many turns back) — within a turn by Self::find_key’s rule, the strongest key first, the same rule key_first applies; the language and the field come from turns[0] — the question being asked now. An empty turns is Found::NoKey.

Source

pub fn answer_for_key( &self, key: KeyHit, message: &str, ) -> Result<Found, String>

The card of a key already found (by Self::find_key, Self::find_strong_key, or in an earlier turn), answering message: the language by its script (an empty slot falls back to the first language with text), the field by its keywords. Found::EmptyCard when the entry has no text in any language.

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<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, 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<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