[][src]Trait rustfst::Semiring

pub trait Semiring: Clone + PartialEq + PartialOrd + Debug + Hash + Eq + Sync + 'static {
    type Type: Clone + Debug;
    type ReverseWeight: Semiring + ReverseBack<Self>;
    fn zero() -> Self;
fn one() -> Self;
fn new(value: Self::Type) -> Self;
fn plus_assign<P: Borrow<Self>>(&mut self, rhs: P) -> Result<()>;
fn times_assign<P: Borrow<Self>>(&mut self, rhs: P) -> Result<()>;
fn value(&self) -> &Self::Type;
fn take_value(self) -> Self::Type;
fn set_value(&mut self, value: Self::Type);
fn reverse(&self) -> Result<Self::ReverseWeight>;
fn properties() -> SemiringProperties; fn plus<P: Borrow<Self>>(&self, rhs: P) -> Result<Self> { ... }
fn times<P: Borrow<Self>>(&self, rhs: P) -> Result<Self> { ... }
fn is_one(&self) -> bool { ... }
fn is_zero(&self) -> bool { ... } }

For some operations, the weight set associated to a wFST must have the structure of a semiring. (S, +, *, 0, 1) is a semiring if (S, +, 0) is a commutative monoid with identity element 0, (S, *, 1) is a monoid with identity element 1, * distributes over +, 0 is an annihilator for *. Thus, a semiring is a ring that may lack negation. For more information : https://cs.nyu.edu/~mohri/pub/hwa.pdf

Associated Types

Loading content...

Required methods

fn zero() -> Self

fn one() -> Self

fn new(value: Self::Type) -> Self

fn plus_assign<P: Borrow<Self>>(&mut self, rhs: P) -> Result<()>

fn times_assign<P: Borrow<Self>>(&mut self, rhs: P) -> Result<()>

fn value(&self) -> &Self::Type

Borrow underneath value.

fn take_value(self) -> Self::Type

Move underneath value.

fn set_value(&mut self, value: Self::Type)

fn reverse(&self) -> Result<Self::ReverseWeight>

fn properties() -> SemiringProperties

Loading content...

Provided methods

fn plus<P: Borrow<Self>>(&self, rhs: P) -> Result<Self>

fn times<P: Borrow<Self>>(&self, rhs: P) -> Result<Self>

fn is_one(&self) -> bool

fn is_zero(&self) -> bool

Loading content...

Implementors

impl Semiring for BooleanWeight[src]

type Type = bool

type ReverseWeight = BooleanWeight

impl Semiring for IntegerWeight[src]

type Type = i32

type ReverseWeight = IntegerWeight

impl Semiring for LogWeight[src]

type Type = f32

type ReverseWeight = LogWeight

impl Semiring for ProbabilityWeight[src]

type Type = f32

type ReverseWeight = ProbabilityWeight

impl Semiring for StringWeightLeft[src]

type Type = StringWeightVariant

type ReverseWeight = StringWeightRight

impl Semiring for StringWeightRestrict[src]

type Type = StringWeightVariant

type ReverseWeight = StringWeightRestrict

impl Semiring for StringWeightRight[src]

type Type = StringWeightVariant

type ReverseWeight = StringWeightLeft

impl Semiring for TropicalWeight[src]

type Type = f32

type ReverseWeight = TropicalWeight

impl<W1, W2> Semiring for ProductWeight<W1, W2> where
    W1: Semiring,
    W2: Semiring
[src]

type Type = (W1, W2)

type ReverseWeight = ProductWeight<W1::ReverseWeight, W2::ReverseWeight>

impl<W> Semiring for GallicWeightLeft<W> where
    W: Semiring
[src]

type Type = ProductWeight<StringWeightLeft, W>

type ReverseWeight = GallicWeightRight<W::ReverseWeight>

impl<W> Semiring for GallicWeightMin<W> where
    W: Semiring
[src]

type Type = ProductWeight<StringWeightRestrict, W>

type ReverseWeight = GallicWeightMin<W::ReverseWeight>

impl<W> Semiring for GallicWeightRestrict<W> where
    W: Semiring
[src]

type Type = ProductWeight<StringWeightRestrict, W>

type ReverseWeight = GallicWeightRestrict<W::ReverseWeight>

impl<W> Semiring for GallicWeightRight<W> where
    W: Semiring
[src]

type Type = ProductWeight<StringWeightRight, W>

type ReverseWeight = GallicWeightLeft<W::ReverseWeight>

impl<W: Semiring> Semiring for GallicWeight<W>[src]

type Type = Vec<GallicWeightRestrict<W>>

type ReverseWeight = GallicWeight<W::ReverseWeight>

impl<W: Semiring, O: UnionWeightOption<W>> Semiring for UnionWeight<W, O>[src]

type Type = Vec<W>

type ReverseWeight = UnionWeight<W::ReverseWeight, O::ReverseOptions>

Loading content...