pub struct LookupTable {
pub id: String,
pub info: LookupInfo,
/* private fields */
}Expand description
One mounted lookup record.
Fields§
§id: String§info: LookupInfoImplementations§
Source§impl LookupTable
impl LookupTable
Sourcepub fn record<'a>(model: &'a CmfModel, id: &str) -> Option<&'a SkillRecord>
pub fn record<'a>(model: &'a CmfModel, id: &str) -> Option<&'a SkillRecord>
The record id when it is a lookup record.
pub fn is_lookup(model: &CmfModel, id: &str) -> bool
Sourcepub fn lookup_ids(model: &CmfModel) -> Vec<String>
pub fn lookup_ids(model: &CmfModel) -> Vec<String>
Ids of every lookup record of the file, in header order.
Sourcepub fn open(model: &Arc<CmfModel>, id: &str) -> Result<Self, String>
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.
pub fn keys(&self) -> usize
Sourcepub fn recovered_keys(&self) -> usize
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).
pub fn entries(&self) -> usize
pub fn langs(&self) -> &[String]
pub fn fields(&self) -> &[String]
Sourcepub fn find_hash(&self, h: u64) -> Option<u32>
pub fn find_hash(&self, h: u64) -> Option<u32>
The entry of key hash h (binary search over the sorted hashes).
Sourcepub fn find_stem_hash(&self, h: u64) -> Option<u32>
pub fn find_stem_hash(&self, h: u64) -> Option<u32>
The entry of stem hash h (StemIndex::find).
Sourcepub fn slot_text(&self, entry: u32, lang: usize) -> Option<&str>
pub fn slot_text(&self, entry: u32, lang: usize) -> Option<&str>
The raw slot text of entry in language index lang.
Sourcepub fn card(&self, entry: u32, lang: usize) -> Result<Card, String>
pub fn card(&self, entry: u32, lang: usize) -> Result<Card, String>
The parsed card of entry in language index lang.
Sourcepub fn find_key(&self, message: &str) -> Option<KeyHit>
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).
Sourcepub fn find_strong_key(&self, message: &str) -> Option<KeyHit>
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).
Sourcepub fn policy(&self) -> LookupPolicy
pub fn policy(&self) -> LookupPolicy
The record’s routing policy (LookupPolicy::of: a value this
reader does not know is router_and_key).
Sourcepub fn answer(&self, message: &str) -> Result<Option<LookupAnswer>, String>
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).
Sourcepub fn find_answer(&self, message: &str) -> Result<Found, String>
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.
Sourcepub fn find_answer_turns(&self, turns: &[&str]) -> Result<Found, String>
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.
Sourcepub fn answer_for_key(
&self,
key: KeyHit,
message: &str,
) -> Result<Found, String>
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.