pub struct Engine { /* private fields */ }Expand description
The engine: a registry plus the common workflows.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn with_registry(registry: Registry) -> Self
pub fn with_registry(registry: Registry) -> Self
An engine around a caller-built registry.
pub fn registry(&self) -> &Registry
Sourcepub fn registry_mut(&mut self) -> &mut Registry
pub fn registry_mut(&mut self) -> &mut Registry
Add algorithms or adapters without touching KUTE’s own crates.
Sourcepub fn train(
&self,
algorithm: &str,
adapter: &str,
adapter_config: &AdapterConfig,
documents: &[Vec<u8>],
config: &TrainingConfig,
) -> Result<Vocabulary>
pub fn train( &self, algorithm: &str, adapter: &str, adapter_config: &AdapterConfig, documents: &[Vec<u8>], config: &TrainingConfig, ) -> Result<Vocabulary>
Train algorithm on raw documents read through adapter.
The adapter and its options are recorded in the vocabulary, so encoding and decoding later go through the same adapter without being told.
Sourcepub fn train_paths(
&self,
algorithm: &str,
adapter: &str,
adapter_config: &AdapterConfig,
paths: &[PathBuf],
config: &TrainingConfig,
) -> Result<Vocabulary>
pub fn train_paths( &self, algorithm: &str, adapter: &str, adapter_config: &AdapterConfig, paths: &[PathBuf], config: &TrainingConfig, ) -> Result<Vocabulary>
Train on files. A directory is read recursively, in sorted path order.
Sourcepub fn tokenizer(&self, vocabulary: Vocabulary) -> Result<Box<dyn Tokenizer>>
pub fn tokenizer(&self, vocabulary: Vocabulary) -> Result<Box<dyn Tokenizer>>
A tokenizer with vocabulary installed.
Sourcepub fn encode_raw(
&self,
tokenizer: &dyn Tokenizer,
raw: &[u8],
) -> Result<TokenSequence>
pub fn encode_raw( &self, tokenizer: &dyn Tokenizer, raw: &[u8], ) -> Result<TokenSequence>
Raw bytes to tokens, through the vocabulary’s adapter.
Sourcepub fn decode_raw(
&self,
tokenizer: &dyn Tokenizer,
tokens: &TokenSequence,
) -> Result<Vec<u8>>
pub fn decode_raw( &self, tokenizer: &dyn Tokenizer, tokens: &TokenSequence, ) -> Result<Vec<u8>>
Tokens back to raw bytes, through the vocabulary’s adapter.
Sourcepub fn encode_batch(
&self,
tokenizer: &dyn Tokenizer,
documents: &[Vec<u8>],
) -> Result<Vec<TokenSequence>>
pub fn encode_batch( &self, tokenizer: &dyn Tokenizer, documents: &[Vec<u8>], ) -> Result<Vec<TokenSequence>>
Encode many documents in parallel. Output order matches input order.
Sourcepub fn verify(&self, vocabulary: &Vocabulary) -> Result<VerifyReport>
pub fn verify(&self, vocabulary: &Vocabulary) -> Result<VerifyReport>
Run the vocabulary’s embedded test vectors: each input must encode to the recorded ids and decode back to the input.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Engine
impl !UnwindSafe for Engine
impl Forget for Engine
impl Freeze for Engine
impl Move for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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 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> ⓘ
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