[−][src]Trait rustfst::fst_traits::CoreFst
Trait defining necessary methods for a wFST to access start states and final states.
Associated Types
Loading content...Required methods
fn start(&self) -> Option<StateId>
Returns the ID of the start state of the wFST if it exists else none.
Example
// 1 - Create an FST let mut fst = VectorFst::<BooleanWeight>::new(); let s = fst.add_state(); fst.set_start(s); // 2 - Access the start state let start_state = fst.start(); assert_eq!(start_state, Some(s));
fn final_weight(&self, state_id: StateId) -> Result<Option<W>>
Retrieves the final weight of a state (if the state is a final one).
Example
// 1 - Create an FST let mut fst = VectorFst::<BooleanWeight>::new(); let s1 = fst.add_state(); let s2 = fst.add_state(); fst.set_final(s2, BooleanWeight::one()); // 2 - Access the final weight of each state assert_eq!(fst.final_weight(s1).unwrap(), None); assert_eq!(fst.final_weight(s2).unwrap(), Some(BooleanWeight::one())); assert!(fst.final_weight(s2 + 1).is_err());
unsafe fn final_weight_unchecked(&self, state_id: StateId) -> Option<W>
fn num_trs(&self, s: StateId) -> Result<usize>
Number of trs leaving a specific state in the wFST.
Example
let mut fst = VectorFst::<BooleanWeight>::new(); let s1 = fst.add_state(); let s2 = fst.add_state(); assert_eq!(fst.num_trs(s1).unwrap(), 0); fst.add_tr(s1, Tr::new(3, 5, BooleanWeight::new(true), s2)); assert_eq!(fst.num_trs(s1).unwrap(), 1);
unsafe fn num_trs_unchecked(&self, s: StateId) -> usize
fn get_trs(&self, state_id: StateId) -> Result<Self::TRS>
unsafe fn get_trs_unchecked(&self, state_id: StateId) -> Self::TRS
fn properties(&self) -> FstProperties
Retrieve the FstProperties
stored in the Fst. As a result, all the properties returned
are verified by the Fst but some other properties might be true as well despite the flag
not being set.
fn num_input_epsilons(&self, state: StateId) -> Result<usize>
Returns the number of trs with epsilon input labels leaving a state.
Example :
let mut fst = VectorFst::<IntegerWeight>::new(); let s0 = fst.add_state(); let s1 = fst.add_state(); fst.add_tr(s0, Tr::new(EPS_LABEL, 18, IntegerWeight::one(), s1)); fst.add_tr(s0, Tr::new(76, EPS_LABEL, IntegerWeight::one(), s1)); fst.add_tr(s0, Tr::new(EPS_LABEL, 18, IntegerWeight::one(), s1)); fst.add_tr(s0, Tr::new(45, 18, IntegerWeight::one(), s0)); fst.add_tr(s1, Tr::new(76, 18, IntegerWeight::one(), s1)); assert_eq!(fst.num_input_epsilons(s0).unwrap(), 2); assert_eq!(fst.num_input_epsilons(s1).unwrap(), 0);
fn num_output_epsilons(&self, state: StateId) -> Result<usize>
Returns the number of trs with epsilon output labels leaving a state.
Example :
let mut fst = VectorFst::<IntegerWeight>::new(); let s0 = fst.add_state(); let s1 = fst.add_state(); fst.add_tr(s0, Tr::new(EPS_LABEL, 18, IntegerWeight::one(), s1)); fst.add_tr(s0, Tr::new(76, EPS_LABEL, IntegerWeight::one(), s1)); fst.add_tr(s0, Tr::new(EPS_LABEL, 18, IntegerWeight::one(), s1)); fst.add_tr(s0, Tr::new(45, 18, IntegerWeight::one(), s0)); fst.add_tr(s1, Tr::new(76, 18, IntegerWeight::one(), s1)); assert_eq!(fst.num_output_epsilons(s0).unwrap(), 1); assert_eq!(fst.num_output_epsilons(s1).unwrap(), 0);
Provided methods
fn is_final(&self, state_id: StateId) -> Result<bool>
Returns whether or not the state with identifier passed as parameters is a final state.
Example
// 1 - Create an FST let mut fst = VectorFst::<BooleanWeight>::new(); let s1 = fst.add_state(); let s2 = fst.add_state(); fst.set_final(s2, BooleanWeight::one()); // 2 - Test if a state is final assert_eq!(fst.is_final(s1).unwrap(), false); assert_eq!(fst.is_final(s2).unwrap(), true); assert!(fst.is_final(s2 + 1).is_err());
unsafe fn is_final_unchecked(&self, state_id: StateId) -> bool
fn is_start(&self, state_id: StateId) -> bool
Check whether a state is the start state or not.
fn properties_with_mask(&self, mask: FstProperties) -> FstProperties
Apply a mask to the FstProperties returned.
fn properties_check(&self, props_known: FstProperties) -> Result<FstProperties>
Retrieve the FstProperties
in the Fst and check that all the
properties in props_known
are known (not the same as true). If not an error is returned.
A property is known if we known for sure if it is true of false.
Implementations on Foreign Types
impl<W: Semiring, F: CoreFst<W>> CoreFst<W> for Arc<F>
[src]
type TRS = F::TRS
fn start(&self) -> Option<usize>
[src]
fn final_weight(&self, state_id: usize) -> Result<Option<W>>
[src]
unsafe fn final_weight_unchecked(&self, state_id: usize) -> Option<W>
[src]
fn num_trs(&self, s: usize) -> Result<usize>
[src]
unsafe fn num_trs_unchecked(&self, s: usize) -> usize
[src]
fn get_trs(&self, state_id: usize) -> Result<Self::TRS>
[src]
unsafe fn get_trs_unchecked(&self, state_id: usize) -> Self::TRS
[src]
fn properties(&self) -> FstProperties
[src]
fn num_input_epsilons(&self, state: usize) -> Result<usize>
[src]
fn num_output_epsilons(&self, state: usize) -> Result<usize>
[src]
Implementors
impl<W, CFB, Cache> CoreFst<W> for ComposeFst<W, CFB, Cache> where
W: Semiring,
CFB: ComposeFilterBuilder<W>,
Cache: FstCache<W>,
[src]
W: Semiring,
CFB: ComposeFilterBuilder<W>,
Cache: FstCache<W>,
type TRS = TrsVec<W>
fn start(&self) -> Option<usize>
[src]
fn final_weight(&self, state_id: usize) -> Result<Option<W>>
[src]
unsafe fn final_weight_unchecked(&self, state_id: usize) -> Option<W>
[src]
fn num_trs(&self, s: usize) -> Result<usize>
[src]
unsafe fn num_trs_unchecked(&self, s: usize) -> usize
[src]
fn get_trs(&self, state_id: usize) -> Result<Self::TRS>
[src]
unsafe fn get_trs_unchecked(&self, state_id: usize) -> Self::TRS
[src]
fn properties(&self) -> FstProperties
[src]
fn num_input_epsilons(&self, state: usize) -> Result<usize>
[src]
fn num_output_epsilons(&self, state: usize) -> Result<usize>
[src]
impl<W, F> CoreFst<W> for ClosureFst<W, F> where
W: Semiring,
F: Fst<W>,
[src]
W: Semiring,
F: Fst<W>,
type TRS = TrsVec<W>
fn start(&self) -> Option<usize>
[src]
fn final_weight(&self, state_id: usize) -> Result<Option<W>>
[src]
unsafe fn final_weight_unchecked(&self, state_id: usize) -> Option<W>
[src]
fn num_trs(&self, s: usize) -> Result<usize>
[src]
unsafe fn num_trs_unchecked(&self, s: usize) -> usize
[src]
fn get_trs(&self, state_id: usize) -> Result<Self::TRS>
[src]
unsafe fn get_trs_unchecked(&self, state_id: usize) -> Self::TRS
[src]
fn properties(&self) -> FstProperties
[src]
fn num_input_epsilons(&self, state: usize) -> Result<usize>
[src]
fn num_output_epsilons(&self, state: usize) -> Result<usize>
[src]
impl<W, F> CoreFst<W> for ConcatFst<W, F> where
W: Semiring,
F: Fst<W>,
[src]
W: Semiring,
F: Fst<W>,
type TRS = TrsVec<W>
fn start(&self) -> Option<usize>
[src]
fn final_weight(&self, state_id: usize) -> Result<Option<W>>
[src]
unsafe fn final_weight_unchecked(&self, state_id: usize) -> Option<W>
[src]
fn num_trs(&self, s: usize) -> Result<usize>
[src]
unsafe fn num_trs_unchecked(&self, s: usize) -> usize
[src]
fn get_trs(&self, state_id: usize) -> Result<Self::TRS>
[src]
unsafe fn get_trs_unchecked(&self, state_id: usize) -> Self::TRS
[src]
fn properties(&self) -> FstProperties
[src]
fn num_input_epsilons(&self, state: usize) -> Result<usize>
[src]
fn num_output_epsilons(&self, state: usize) -> Result<usize>
[src]
impl<W, F> CoreFst<W> for UnionFst<W, F> where
W: Semiring,
F: Fst<W>,
[src]
W: Semiring,
F: Fst<W>,
type TRS = TrsVec<W>
fn start(&self) -> Option<usize>
[src]
fn final_weight(&self, state_id: usize) -> Result<Option<W>>
[src]
unsafe fn final_weight_unchecked(&self, state_id: usize) -> Option<W>
[src]
fn num_trs(&self, s: usize) -> Result<usize>
[src]
unsafe fn num_trs_unchecked(&self, s: usize) -> usize
[src]
fn get_trs(&self, state_id: usize) -> Result<Self::TRS>
[src]
unsafe fn get_trs_unchecked(&self, state_id: usize) -> Self::TRS
[src]
fn properties(&self) -> FstProperties
[src]
fn num_input_epsilons(&self, state: usize) -> Result<usize>
[src]
fn num_output_epsilons(&self, state: usize) -> Result<usize>
[src]
impl<W, F, B> CoreFst<W> for ReplaceFst<W, F, B> where
W: Semiring,
F: Fst<W>,
B: Borrow<F>,
[src]
W: Semiring,
F: Fst<W>,
B: Borrow<F>,
type TRS = TrsVec<W>
fn start(&self) -> Option<usize>
[src]
fn final_weight(&self, state_id: usize) -> Result<Option<W>>
[src]
unsafe fn final_weight_unchecked(&self, state_id: usize) -> Option<W>
[src]
fn num_trs(&self, s: usize) -> Result<usize>
[src]
unsafe fn num_trs_unchecked(&self, s: usize) -> usize
[src]
fn get_trs(&self, state_id: usize) -> Result<Self::TRS>
[src]
unsafe fn get_trs_unchecked(&self, state_id: usize) -> Self::TRS
[src]
fn properties(&self) -> FstProperties
[src]
fn num_input_epsilons(&self, state: usize) -> Result<usize>
[src]
fn num_output_epsilons(&self, state: usize) -> Result<usize>
[src]
impl<W, F, B> CoreFst<W> for RmEpsilonFst<W, F, B> where
W: Semiring,
F: MutableFst<W>,
B: Borrow<F>,
[src]
W: Semiring,
F: MutableFst<W>,
B: Borrow<F>,
type TRS = TrsVec<W>
fn start(&self) -> Option<usize>
[src]
fn final_weight(&self, state_id: usize) -> Result<Option<W>>
[src]
unsafe fn final_weight_unchecked(&self, state_id: usize) -> Option<W>
[src]
fn num_trs(&self, s: usize) -> Result<usize>
[src]
unsafe fn num_trs_unchecked(&self, s: usize) -> usize
[src]
fn get_trs(&self, state_id: usize) -> Result<Self::TRS>
[src]
unsafe fn get_trs_unchecked(&self, state_id: usize) -> Self::TRS
[src]
fn properties(&self) -> FstProperties
[src]
fn num_input_epsilons(&self, state: usize) -> Result<usize>
[src]
fn num_output_epsilons(&self, state: usize) -> Result<usize>
[src]
impl<W, F, B, FI> CoreFst<W> for FactorWeightFst<W, F, B, FI> where
W: WeightQuantize,
F: Fst<W>,
B: Borrow<F>,
FI: FactorIterator<W>,
[src]
W: WeightQuantize,
F: Fst<W>,
B: Borrow<F>,
FI: FactorIterator<W>,