pub struct DenseFst<'a, A: Arc> { /* private fields */ }Expand description
A T × V matrix of acoustic scores, read as an FST.
Row-major: the score of symbol c in frame t is scores[t * V + c].
Implementations§
Source§impl<'a, A: Arc> DenseFst<'a, A>
impl<'a, A: Arc> DenseFst<'a, A>
Sourcepub fn new(
scores: &'a [f32],
num_frames: usize,
num_symbols: usize,
) -> Result<Self, OpenFstError>
pub fn new( scores: &'a [f32], num_frames: usize, num_symbols: usize, ) -> Result<Self, OpenFstError>
Reads scores as num_frames × num_symbols, with column c as label
c + 1.
Sourcepub fn with_label_offset(
scores: &'a [f32],
num_frames: usize,
num_symbols: usize,
label_offset: i64,
) -> Result<Self, OpenFstError>
pub fn with_label_offset( scores: &'a [f32], num_frames: usize, num_symbols: usize, label_offset: i64, ) -> Result<Self, OpenFstError>
As new, with the columns placed at a chosen label.
An offset of 0 puts column 0 on epsilon; that is allowed, because a graph may genuinely want it, but the properties then say so.
Sourcepub fn num_frames(&self) -> usize
pub fn num_frames(&self) -> usize
The number of frames, which is one less than the number of states.
Sourcepub fn num_symbols(&self) -> usize
pub fn num_symbols(&self) -> usize
The number of symbols the acoustic model scores.
Sourcepub fn label_offset(&self) -> i64
pub fn label_offset(&self) -> i64
The label column 0 was placed on.
Trait Implementations§
Source§impl<A: Arc> ExpandedFst<A> for DenseFst<'_, A>
impl<A: Arc> ExpandedFst<A> for DenseFst<'_, A>
Source§fn num_states(&self) -> usize
fn num_states(&self) -> usize
Returns the total number of states in the FST.
Source§impl<A: Arc> Fst<A> for DenseFst<'_, A>
impl<A: Arc> Fst<A> for DenseFst<'_, A>
Source§type StateIter<'s> = DenseStateIter<A>
where
Self: 's
type StateIter<'s> = DenseStateIter<A> where Self: 's
An iterator over the states of the FST.
Source§type ArcIter<'s> = DenseArcIter<'s, A>
where
Self: 's
type ArcIter<'s> = DenseArcIter<'s, A> where Self: 's
An iterator over the outgoing arcs of a state.
Clone is required to allow multi-pass algorithms (e.g., matchers in Compose)
to save and restore iteration positions effortlessly without C++ Seek or Reset.Source§fn start(&self) -> Option<A::StateId>
fn start(&self) -> Option<A::StateId>
Returns the initial state ID, or
None if the FST is empty.Source§fn final_weight(&self, state: A::StateId) -> A::Weight
fn final_weight(&self, state: A::StateId) -> A::Weight
Returns the final weight of the given state.
If the state is not final, this must return
Weight::zero().Source§fn num_arcs(&self, state: A::StateId) -> usize
fn num_arcs(&self, state: A::StateId) -> usize
Returns the number of arcs leaving the given state.
Source§fn num_input_epsilons(&self, state: A::StateId) -> usize
fn num_input_epsilons(&self, state: A::StateId) -> usize
Returns the number of input epsilon arcs leaving the given state.
Source§fn num_output_epsilons(&self, state: A::StateId) -> usize
fn num_output_epsilons(&self, state: A::StateId) -> usize
Returns the number of output epsilon arcs leaving the given state.
Source§fn num_states_if_known(&self) -> Option<usize>
fn num_states_if_known(&self) -> Option<usize>
Returns the number of states if it is finite and can be computed in O(1) time.
Otherwise returns
None.Source§fn properties(&self, mask: u64, _test: bool) -> u64
fn properties(&self, mask: u64, _test: bool) -> u64
Property bits.
If
test is false, returns stored properties bits (some possibly unknown).
If test is true, computes the properties if they are unknown.Source§fn input_symbols(&self) -> Option<AtomicRc<SymbolTable>>
fn input_symbols(&self) -> Option<AtomicRc<SymbolTable>>
Returns the input label symbol table, if any.
Using
Arc allows cheap sharing across FST operations.Source§fn output_symbols(&self) -> Option<AtomicRc<SymbolTable>>
fn output_symbols(&self) -> Option<AtomicRc<SymbolTable>>
Returns the output label symbol table, if any.
Source§fn states<'s>(&'s self) -> Self::StateIter<'s>
fn states<'s>(&'s self) -> Self::StateIter<'s>
Returns an iterator over all state IDs in the FST.
Source§fn arcs<'s>(&'s self, state: A::StateId) -> Self::ArcIter<'s>
fn arcs<'s>(&'s self, state: A::StateId) -> Self::ArcIter<'s>
Returns an iterator over the outgoing arcs of the given state.
Source§fn count_states(&self) -> usize
fn count_states(&self) -> usize
Computes the exact number of states in the FST.
If the state count is known in O(1) (i.e.
num_states_if_known returns Some),
it uses that. Otherwise, it iterates through all states in O(V) time.Source§fn count_arcs(&self) -> usize
fn count_arcs(&self) -> usize
Computes the exact number of arcs in the FST in O(V) time.
Auto Trait Implementations§
impl<'a, A> Freeze for DenseFst<'a, A>where
PhantomData<A>: Freeze,
impl<'a, A> RefUnwindSafe for DenseFst<'a, A>where
PhantomData<A>: RefUnwindSafe,
impl<'a, A> Send for DenseFst<'a, A>where
PhantomData<A>: Send,
impl<'a, A> Sync for DenseFst<'a, A>where
PhantomData<A>: Sync,
impl<'a, A> Unpin for DenseFst<'a, A>where
PhantomData<A>: Unpin,
impl<'a, A> UnsafeUnpin for DenseFst<'a, A>where
PhantomData<A>: UnsafeUnpin,
impl<'a, A> UnwindSafe for DenseFst<'a, A>where
PhantomData<A>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more