pub struct CategoricalEncoder<E, V, M>where
    V: Clone + Eq + Hash,
    M: Number<V>,{ /* private fields */ }
Expand description

An encoder wrapper that encodes/decodes to a categorical label.

Implementations§

source§

impl<E, V, M> CategoricalEncoder<E, V, M>where V: Clone + Eq + Hash, M: Number<V>,

source

pub fn new(encoder: E, numberer: Numberer<V>) -> Self

source§

impl<D, M> CategoricalEncoder<D, D::Encoding, M>where D: SentenceDecoder, D::Encoding: Clone + Eq + Hash + ToOwned, M: Number<D::Encoding>,

source

pub fn decode_without_inner<S>( &self, labels: &[S] ) -> Vec<Vec<EncodingProb<D::Encoding>>>where S: AsRef<[EncodingProb<usize>]>,

Decode without applying the inner decoder.

source§

impl<E, V, M> CategoricalEncoder<E, V, M>where V: Clone + Eq + Hash, M: Number<V>,

source

pub fn is_empty(&self) -> bool

source

pub fn len(&self) -> usize

Trait Implementations§

source§

impl<'de, E, V, M> Deserialize<'de> for CategoricalEncoder<E, V, M>where V: Clone + Eq + Hash, M: Number<V> + Deserialize<'de>, E: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<D, M> SentenceDecoder for CategoricalEncoder<D, D::Encoding, M>where D: SentenceDecoder, D::Encoding: Clone + Eq + Hash, M: Number<D::Encoding>,

§

type Encoding = usize

§

type Error = <D as SentenceDecoder>::Error

The decoding error type.
source§

fn decode<S>( &self, labels: &[S], sentence: &mut Sentence ) -> Result<(), Self::Error>where S: AsRef<[EncodingProb<Self::Encoding>]>,

source§

impl<E, M> SentenceEncoder for CategoricalEncoder<E, E::Encoding, M>where E: SentenceEncoder, E::Encoding: Clone + Eq + Hash, M: Number<E::Encoding>,

§

type Encoding = usize

§

type Error = <E as SentenceEncoder>::Error

The encoding error type.
source§

fn encode( &self, sentence: &Sentence ) -> Result<Vec<Self::Encoding>, Self::Error>

Encode the given sentence.
source§

impl<E, V, M> Serialize for CategoricalEncoder<E, V, M>where V: Clone + Eq + Hash, M: Number<V> + Serialize, E: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<E, V, M> RefUnwindSafe for CategoricalEncoder<E, V, M>where E: RefUnwindSafe, M: RefUnwindSafe, V: RefUnwindSafe,

§

impl<E, V, M> Send for CategoricalEncoder<E, V, M>where E: Send, M: Send, V: Send,

§

impl<E, V, M> Sync for CategoricalEncoder<E, V, M>where E: Sync, M: Sync, V: Sync,

§

impl<E, V, M> Unpin for CategoricalEncoder<E, V, M>where E: Unpin, M: Unpin, V: Unpin,

§

impl<E, V, M> UnwindSafe for CategoricalEncoder<E, V, M>where E: UnwindSafe, M: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,