Trait tongrams::vocabulary::Vocabulary
source ·
[−]pub trait Vocabulary {
fn new() -> Box<Self>;
fn build(tokens: &[Gram<'_>]) -> Result<Box<Self>>;
fn serialize_into<W: Write>(&self, writer: W) -> Result<usize>;
fn deserialize_from<R: Read>(reader: R) -> Result<Box<Self>>;
fn size_in_bytes(&self) -> usize;
fn memory_statistics(&self) -> Value;
fn get(&self, token: Gram<'_>) -> Option<usize>;
}
Expand description
Trait for a data structure for mapping tokens to unique identifiers.
Required methods
Creates an empty Vocabulary
.
Builds a Vocabulary
from a sequence of tokens.
fn serialize_into<W: Write>(&self, writer: W) -> Result<usize>
fn serialize_into<W: Write>(&self, writer: W) -> Result<usize>
Serializes the data structure into the writer.
fn deserialize_from<R: Read>(reader: R) -> Result<Box<Self>>
fn deserialize_from<R: Read>(reader: R) -> Result<Box<Self>>
Deserializes the data structure from the reader.
fn size_in_bytes(&self) -> usize
fn size_in_bytes(&self) -> usize
Gets the number of bytes to serialize the data structure.
fn memory_statistics(&self) -> Value
fn memory_statistics(&self) -> Value
Gets breakdowns of memory usages for components.