[][src]Trait finalfrontier::Vocab

pub trait Vocab {
type VocabType;
type Config;
    fn config(&self) -> Self::Config;
fn idx<Q: ?Sized>(&self, key: &Q) -> Option<usize>
    where
        Self::VocabType: Borrow<Q>,
        Q: Hash + Eq
;
fn discard(&self, idx: usize) -> f32;
fn types(&self) -> &[CountedType<Self::VocabType>];
fn n_types(&self) -> usize; fn is_empty(&self) -> bool { ... }
fn len(&self) -> usize { ... } }

Trait for lookup of indices.

Associated Types

type VocabType

type Config

Loading content...

Required methods

fn config(&self) -> Self::Config

Return this vocabulary's config.

fn idx<Q: ?Sized>(&self, key: &Q) -> Option<usize> where
    Self::VocabType: Borrow<Q>,
    Q: Hash + Eq

Get the index of the entry, will return None if the item is not present.

fn discard(&self, idx: usize) -> f32

Get the discard probability of the entry with the given index.

fn types(&self) -> &[CountedType<Self::VocabType>]

Get all types in the vocabulary.

fn n_types(&self) -> usize

Get the number of types in the corpus.

This returns the number of types in the corpus that the vocabulary was constructed from, before removing types that are below the minimum count.

Loading content...

Provided methods

fn is_empty(&self) -> bool

fn len(&self) -> usize

Get the number of entries in the vocabulary.

Loading content...

Implementors

impl Vocab for SubwordVocab[src]

type VocabType = String

type Config = SubwordVocabConfig

fn is_empty(&self) -> bool[src]

fn len(&self) -> usize[src]

impl<T> Vocab for SimpleVocab<T> where
    T: Hash + Eq
[src]

type VocabType = T

type Config = SimpleVocabConfig

fn is_empty(&self) -> bool[src]

fn len(&self) -> usize[src]

Loading content...