Skip to main content

DenseFst

Struct DenseFst 

Source
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>
where A::Weight: FromScore,

Source

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.

Source

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.

Source

pub fn num_frames(&self) -> usize

The number of frames, which is one less than the number of states.

Source

pub fn num_symbols(&self) -> usize

The number of symbols the acoustic model scores.

Source

pub fn label_offset(&self) -> i64

The label column 0 was placed on.

Source

pub fn frame(&self, t: usize) -> &'a [f32]

The scores of one frame, indexed by column.

A decoder wants exactly this: it walks the graph’s arcs and looks up each one’s label here, rather than iterating this FST’s V arcs and discarding the ones the graph has no use for.

Source

pub fn column_of(&self, label: A::Label) -> Option<usize>

The column a label falls in, or None if it names no column.

Trait Implementations§

Source§

impl<'a, A: Clone + Arc> Clone for DenseFst<'a, A>

Source§

fn clone(&self) -> DenseFst<'a, A>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, A: Debug + Arc> Debug for DenseFst<'a, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: Arc> ExpandedFst<A> for DenseFst<'_, A>
where A::Weight: FromScore,

Source§

fn num_states(&self) -> usize

Returns the total number of states in the FST.
Source§

impl<A: Arc> Fst<A> for DenseFst<'_, A>
where A::Weight: FromScore,

Source§

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

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>

Returns the initial state ID, or None if the FST is empty.
Source§

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

Returns the number of arcs leaving the given state.
Source§

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

Returns the number of output epsilon arcs leaving the given state.
Source§

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

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 fst_type(&self) -> &str

Returns the name of the FST type (e.g., “vector”, “const”).
Source§

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>>

Returns the output label symbol table, if any.
Source§

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>

Returns an iterator over the outgoing arcs of the given state.
Source§

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

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>

§

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>

§

impl<'a, A> UnwindSafe for DenseFst<'a, A>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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<A, F> VerifyExt<A> for F
where A: Arc, F: Fst<A>,

Source§

fn verify<const P: u64>(self) -> Result<Verified<F, P>, OpenFstError>