Struct rustfst::fst_impls::VectorFst

source ·
pub struct VectorFst<W: Semiring> { /* private fields */ }
Expand description

Simple concrete, mutable FST whose states and trs are stored in standard vectors.

All states are stored in a vector of states. In each state, there is a vector of trs containing the outgoing transitions.

Implementations§

source§

impl<W: Semiring> VectorFst<W>

source§

impl<W: SerializableSemiring> VectorFst<W>

source

pub fn read_from_const<P: AsRef<Path>>(path_bin_fst: P) -> Result<Self>

Load a VectorFst directly from a ConstFst file.

Trait Implementations§

source§

impl<W: 'static + Semiring> AllocableFst<W> for VectorFst<W>

source§

fn reserve_trs(&mut self, source: StateId, additional: usize) -> Result<()>

Reserve capacity for at least additional more trs leaving the state. The FST may reserve more space to avoid frequent allocation. After calling reserve_trs, the capacity will be greater or equal to num_trs + additionnal This method has no effects if the capacity is already sufficient
source§

unsafe fn reserve_trs_unchecked(&mut self, source: StateId, additional: usize)

Safety Read more
source§

fn reserve_states(&mut self, additional: usize)

Reserve capacity for at least additional states. The FST may reserve more space to avoid frequent allocation. After calling reserve_states, the capacity will be greater or equal to num_states + additionnal This method has no effects if the capacity is already sufficient
source§

fn shrink_to_fit(&mut self)

Shrinks the capacity of the states and their leaving trs as much as possible. It will drop down as close as possible to the number of states and leaving trs.
source§

fn shrink_to_fit_states(&mut self)

Shrinks the capacity of the states. It will drop down as close as possible to the number of states.
source§

fn shrink_to_fit_trs(&mut self, source: StateId) -> Result<()>

Shrinks the capacity of the leaving trs for the given state as much as possible. It will drop down as close as possible to theleaving trs.
source§

unsafe fn shrink_to_fit_trs_unchecked(&mut self, source: StateId)

Shrinks the capacity of the leaving trs for the given state as much as possible. It will drop down as close as possible to theleaving trs. Read more
source§

fn states_capacity(&self) -> usize

Returns the number of states the FST can hold without reallocating.
source§

fn trs_capacity(&self, source: StateId) -> Result<usize>

Returns the number of trs for a given state the FST can hold without reallocating.
source§

unsafe fn trs_capacity_unchecked(&self, source: StateId) -> usize

Returns the number of trs for a given state the FST can hold without reallocating. Read more
source§

impl<W: Clone + Semiring> Clone for VectorFst<W>

source§

fn clone(&self) -> VectorFst<W>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<W: Semiring> CoreFst<W> for VectorFst<W>

§

type TRS = TrsVec<W>

Weight use in the wFST. This type must implement the Semiring trait.
source§

fn start(&self) -> Option<StateId>

Returns the ID of the start state of the wFST if it exists else none. Read more
source§

fn final_weight(&self, state_id: StateId) -> Result<Option<W>>

Retrieves the final weight of a state (if the state is a final one). Read more
source§

unsafe fn final_weight_unchecked(&self, state_id: StateId) -> Option<W>

Retrieves the final weight of a state (if the state is a final one). Read more
source§

fn num_trs(&self, s: StateId) -> Result<usize>

Number of trs leaving a specific state in the wFST. Read more
source§

unsafe fn num_trs_unchecked(&self, s: StateId) -> usize

Number of trs leaving a specific state in the wFST. Read more
source§

fn get_trs(&self, state_id: StateId) -> Result<Self::TRS>

Get an iterator on the transitions leaving state state.
source§

unsafe fn get_trs_unchecked(&self, state_id: StateId) -> Self::TRS

Get an iterator on the transitions leaving state state. Read more
source§

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.
source§

fn num_input_epsilons(&self, state: StateId) -> Result<usize>

Returns the number of trs with epsilon input labels leaving a state. Read more
source§

fn num_output_epsilons(&self, state: StateId) -> Result<usize>

Returns the number of trs with epsilon output labels leaving a state. Read more
source§

fn is_final(&self, state_id: StateId) -> Result<bool>

Returns whether or not the state with identifier passed as parameters is a final state. Read more
source§

unsafe fn is_final_unchecked(&self, state: StateId) -> bool

Returns whether or not the state with identifier passed as parameters is a final state. Read more
source§

fn is_start(&self, state_id: StateId) -> bool

Check whether a state is the start state or not.
source§

fn properties_with_mask(&self, mask: FstProperties) -> FstProperties

Apply a mask to the FstProperties returned.
source§

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. Read more
source§

impl<W: Debug + Semiring> Debug for VectorFst<W>

source§

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

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

impl<W: 'static + SerializableSemiring> Display for VectorFst<W>

source§

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

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

impl<W: 'static + Semiring> ExpandedFst<W> for VectorFst<W>

source§

fn num_states(&self) -> usize

Returns the number of states that contains the FST. They are all counted even if some states are not on a successful path (doesn’t perform triming). Read more
source§

fn states_range(&self) -> Range<StateId>

source§

fn approx_equal<F2: ExpandedFst<W>>(&self, fst2: &F2, delta: f32) -> bool

source§

impl<W: Semiring> From<VectorFst<W>> for ConstFst<W>

source§

fn from(ifst: VectorFst<W>) -> Self

Converts to this type from the input type.
source§

impl<W: Semiring> Fst<W> for VectorFst<W>

source§

fn input_symbols(&self) -> Option<&Arc<SymbolTable>>

Retrieves the input SymbolTable associated to the Fst. If no SymbolTable has been previously attached then None is returned.
source§

fn output_symbols(&self) -> Option<&Arc<SymbolTable>>

Retrieves the output SymbolTable associated to the Fst. If no SymbolTable has been previously attached then None is returned.
source§

fn set_input_symbols(&mut self, symt: Arc<SymbolTable>)

Attaches an output SymbolTable to the Fst. The SymbolTable is not duplicated with the use of Arc.
source§

fn set_output_symbols(&mut self, symt: Arc<SymbolTable>)

Attaches an output SymbolTable to the Fst. The SymbolTable is not duplicated with the use of Arc.
source§

fn take_input_symbols(&mut self) -> Option<Arc<SymbolTable>>

Removes the input symbol table from the Fst and retrieves it.
source§

fn take_output_symbols(&mut self) -> Option<Arc<SymbolTable>>

Removes the output symbol table from the Fst and retrieves it.
source§

fn final_states_iter(&self) -> FinalStatesIterator<'_, W, Self>
where Self: Sized,

Returns an Iterator on the final states along with their weight.
source§

fn paths_iter(&self) -> PathsIterator<'_, W, Self>
where Self: Sized,

Returns an Iterator on the paths accepted by the Fst. Read more
source§

fn string_paths_iter(&self) -> Result<StringPathsIterator<'_, W, Self>>
where Self: Sized,

Returns an Iterator on the paths accepted by the Fst. Plus, handles the SymbolTable allowing to retrieve the strings instead of only the sequence of labels. Read more
source§

impl<W: Semiring> FstIntoIterator<W> for VectorFst<W>

§

type TrsIter = IntoIter<Tr<W>>

§

type FstIter = Box<dyn Iterator<Item = FstIterData<W, <VectorFst<W> as FstIntoIterator<W>>::TrsIter>>>

source§

fn fst_into_iter(self) -> Self::FstIter

source§

impl<'a, W: Semiring + 'static> FstIterator<'a, W> for VectorFst<W>

§

type FstIter = Map<Enumerate<Iter<'a, VectorFstState<W>>>, Box<dyn FnMut((usize, &'a VectorFstState<W>)) -> FstIterData<W, <VectorFst<W> as CoreFst<W>>::TRS>>>

source§

fn fst_iter(&'a self) -> Self::FstIter

source§

impl<W: Semiring> MutableFst<W> for VectorFst<W>

source§

fn sort_trs_unchecked<F: Fn(&Tr<W>, &Tr<W>) -> Ordering>( &mut self, state: StateId, f: F )

DOESN’T MODIFY THE PROPERTIES

source§

unsafe fn unique_trs_unchecked(&mut self, state: StateId)

DOESN’T MODIFY THE PROPERTIES

source§

unsafe fn sum_trs_unchecked(&mut self, state: StateId)

DOESN’T MODIFY THE PROPERTIES

source§

fn new() -> Self

Creates an empty wFST.
source§

fn set_start(&mut self, state_id: StateId) -> Result<()>

The state with identifier state_id is now the start state. Note that only one start state is allowed in this implementation. Calling this function twice will mean losing the first start state. If the state_id doesn’t exist an error is raised. Read more
source§

unsafe fn set_start_unchecked(&mut self, state_id: StateId)

The state with identifier state_id is now the start state. Read more
source§

fn set_final<S: Into<W>>( &mut self, state_id: StateId, final_weight: S ) -> Result<()>

The state with identifier state_id is now a final state with a weight final_weight. If the state_id doesn’t exist an error is raised. Read more
source§

unsafe fn set_final_unchecked<S: Into<W>>( &mut self, state_id: StateId, final_weight: S )

Set the final weight of the state with state if state_id. Read more
source§

fn add_state(&mut self) -> StateId

Adds a new state to the current FST. The identifier of the new state is returned Read more
source§

fn add_states(&mut self, n: usize)

Add n states to the Fst.
source§

fn tr_iter_mut(&mut self, state_id: StateId) -> Result<TrsIterMut<'_, W>>

Return a mutable iterator on the Trs of the state state.
source§

unsafe fn tr_iter_unchecked_mut( &mut self, state_id: StateId ) -> TrsIterMut<'_, W>

Return a mutable iterator on the Trs of the state state. Read more
source§

fn del_state(&mut self, state_to_remove: StateId) -> Result<()>

Removes a state from an FST. It also removes all the trs starting from another state and reaching this state. An error is raised if the state state_id doesn’t exist. Read more
source§

fn del_states<T: IntoIterator<Item = StateId>>( &mut self, dstates: T ) -> Result<()>

Removes multiple states from an FST. If one of the states doesn’t exist, an error is raised. Read more
source§

fn del_all_states(&mut self)

Remove all the states in the FST. As a result, all the trs are also removed, as well as the start state and all the fina states. Read more
source§

unsafe fn del_trs_id_sorted_unchecked( &mut self, state: StateId, to_del: &[usize] )

Remove transitions from the fst at state state. Transitions are specified with their index. The to_del vector MUST be sorted. Read more
source§

fn add_tr(&mut self, source: StateId, tr: Tr<W>) -> Result<()>

Adds a transition to the FST. The transition will start in the state source. Read more
source§

unsafe fn add_tr_unchecked(&mut self, source: StateId, tr: Tr<W>)

Adds a transition to the FST. The transition will start in the state state. Read more
source§

unsafe fn set_trs_unchecked(&mut self, source: StateId, trs: Vec<Tr<W>>)

Set all the Trs leaving the state state to the parameters trs erasing the Trs previously stored. Read more
source§

fn delete_final_weight(&mut self, source: StateId) -> Result<()>

Remove the final weight of a specific state.
source§

unsafe fn delete_final_weight_unchecked(&mut self, source: StateId)

Remove the final weight of state state. Read more
source§

fn delete_trs(&mut self, source: StateId) -> Result<()>

Deletes all the trs leaving a state.
source§

fn pop_trs(&mut self, source: StateId) -> Result<Vec<Tr<W>>>

Remove all trs leaving a state and return them.
source§

unsafe fn pop_trs_unchecked(&mut self, source: StateId) -> Vec<Tr<W>>

Remove all the Tr leaving the state state and return them. Read more
source§

fn take_final_weight(&mut self, state_id: StateId) -> Result<Option<W>>

Takes the final weight out of the fst, leaving a None in its place. Read more
source§

unsafe fn take_final_weight_unchecked(&mut self, state_id: StateId) -> Option<W>

Takes the final weight out of the fst, leaving a None in its place. This version leads to undefined behaviour if the state doesn’t exist. Read more
source§

fn set_properties(&mut self, props: FstProperties)

Set the internal properties of the Fst. All the set properties must be verified by the Fst!
source§

fn set_properties_with_mask( &mut self, props: FstProperties, mask: FstProperties )

Set only a subset of the internal properties of the Fst.
source§

fn emplace_tr<S: Into<W>>( &mut self, source: StateId, ilabel: Label, olabel: Label, weight: S, nextstate: StateId ) -> Result<()>

Adds a transition to the FST. The transition will start in the state source. Read more
source§

unsafe fn emplace_tr_unchecked<S: Into<W>>( &mut self, state: StateId, ilabel: Label, olabel: Label, weight: S, nextstate: StateId )

Adds a transition to the FST. The transition will start in the state state. Read more
source§

fn closure(&mut self, closure_type: ClosureType)

This operation computes the concatenative closure. If A transduces string x to y with weight a, then the closure transduces x to y with weight a, xx to yy with weight a ⊗ a, xxx to yyy with weight a ⊗ a ⊗ a, etc. If closure_star then the empty string is transduced to itself with weight 1 as well.
source§

fn tr_map<M: TrMapper<W>>(&mut self, mapper: &mut M) -> Result<()>

Maps a transition using a TrMapper object.
source§

fn compute_and_update_properties( &mut self, mask: FstProperties ) -> Result<FstProperties>

Compute the properties verified by the Fst (with a mask) and update the internal property bits.
source§

fn compute_and_update_properties_all(&mut self) -> Result<FstProperties>

Compute all the properties verified by the Fst and update the internal property bits.
source§

fn set_symts_from_fst<W2: Semiring, OF: Fst<W2>>(&mut self, other_fst: &OF)

source§

fn relabel_tables( &mut self, old_isymbols: Option<&Arc<SymbolTable>>, new_isymbols: &Arc<SymbolTable>, attach_new_isymbols: bool, old_osymbols: Option<&Arc<SymbolTable>>, new_osymbols: &Arc<SymbolTable>, attach_new_osymbols: bool ) -> Result<()>

Destructively relabel the Fst with new Symbol Tables. Read more
source§

impl<W: Semiring> PartialEq for VectorFst<W>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<W: SerializableSemiring> SerializableFst<W> for VectorFst<W>

source§

fn fst_type() -> String

String identifying the type of the FST. Will be used when serialiing and deserializing an FST in binary format.
source§

fn load(data: &[u8]) -> Result<Self>

Loads an FST from the binary format data in a Read.
source§

fn store<O: Write>(&self, output: O) -> Result<()>

Store the FST in binary format to a Write.
source§

fn from_parsed_fst_text(parsed_fst_text: ParsedTextFst<W>) -> Result<Self>

Turns a generic wFST format into the one of the wFST.
source§

fn read<P: AsRef<Path>>(path_bin_fst: P) -> Result<Self>

Loads an FST from a file in binary format.
source§

fn write<P: AsRef<Path>>(&self, path_bin_fst: P) -> Result<()>

Writes the FST to a file in binary format.
source§

fn from_text_string(fst_string: &str) -> Result<Self>

Deserializes a wFST in text from a path and returns a loaded wFST.
source§

fn read_text<P: AsRef<Path>>(path_text_fst: P) -> Result<Self>

Deserializes a wFST in text from a path and returns a loaded wFST.
source§

fn write_text<P: AsRef<Path>>(&self, path_output: P) -> Result<()>

Serializes the FST as a text file in a format compatible with OpenFST.
source§

fn text(&self) -> Result<String>

Writes the text representation of the FST into a String.
source§

fn draw<P: AsRef<Path>>( &self, path_output: P, config: &DrawingConfig ) -> Result<()>

Serializes the FST as a DOT file compatible with GraphViz binaries.
source§

impl<'a, W: Semiring> StateIterator<'a> for VectorFst<W>

§

type Iter = Range<u32>

Iterator used to iterate over the state_id of the states of an FST.
source§

fn states_iter(&'a self) -> Self::Iter

Creates an iterator over the state_id of the states of an FST. Read more

Auto Trait Implementations§

§

impl<W> Freeze for VectorFst<W>

§

impl<W> RefUnwindSafe for VectorFst<W>
where W: RefUnwindSafe,

§

impl<W> Send for VectorFst<W>
where W: Send,

§

impl<W> Sync for VectorFst<W>
where W: Send,

§

impl<W> Unpin for VectorFst<W>
where W: Unpin,

§

impl<W> UnwindSafe for VectorFst<W>

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> 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V