pub struct Explicit { /* private fields */ }Expand description
A fully materialized bottom-up tree automaton.
Explicit stores transition rules in lookup tables. It is the fastest
representation when all rules are known ahead of time or after an implicit
automaton has been materialized. Rules with arity 0, 1, and 2 use separate
compact tables because those are the common hot paths.
Build values with ExplicitBuilder. Every transition rule has a weight;
callers that do not have natural weights can use 1.0.
Implementations§
Source§impl Explicit
impl Explicit
Sourcepub fn application_summary(&self) -> AutomatonSummary
pub fn application_summary(&self) -> AutomatonSummary
Return an owned summary without exposing internal indexes.
Sourcepub fn language_cardinality(&self) -> LanguageCardinality
pub fn language_cardinality(&self) -> LanguageCardinality
Return the number of accepted derivation trees without enumerating them.
Sourcepub fn resolve_rules(
&self,
state_name: impl FnMut(StateId) -> String,
symbol_name: impl FnMut(Symbol) -> String,
) -> Vec<ResolvedRule>
pub fn resolve_rules( &self, state_name: impl FnMut(StateId) -> String, symbol_name: impl FnMut(Symbol) -> String, ) -> Vec<ResolvedRule>
Resolve rules with caller-supplied state and symbol naming.
Sourcepub fn resolved_rule(
&self,
index: usize,
state_name: impl FnMut(StateId) -> String,
symbol_name: impl FnMut(Symbol) -> String,
) -> ResolvedRule
pub fn resolved_rule( &self, index: usize, state_name: impl FnMut(StateId) -> String, symbol_name: impl FnMut(Symbol) -> String, ) -> ResolvedRule
Resolve a single rule by index with caller-supplied naming.
Source§impl Explicit
impl Explicit
Sourcepub fn num_states(&self) -> u32
pub fn num_states(&self) -> u32
Return the number of allocated states.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return true if no tree can be accepted by this automaton.
This computes reachable states from nullary rules and checks whether any accepting state is reachable.
Sourcepub fn reachable_states(&self) -> FixedBitSet
pub fn reachable_states(&self) -> FixedBitSet
Compute states reachable from nullary rules by saturation.
A state is reachable if some finite tree can receive that state at its root. This is often useful for pruning or quick emptiness checks. The result is cached after the first call because explicit automata are immutable.
Sourcepub fn rules(&self) -> impl Iterator<Item = Rule<'_>>
pub fn rules(&self) -> impl Iterator<Item = Rule<'_>>
Iterate over all transition rules.
The order is stable for a fixed automaton but should not be treated as a semantic ordering.
Sourcepub fn rules_topdown(&self, parent: StateId) -> impl Iterator<Item = Rule<'_>>
pub fn rules_topdown(&self, parent: StateId) -> impl Iterator<Item = Rule<'_>>
Iterate over rules with the given parent/result state.
Sourcepub fn rule(&self, rule_idx: usize) -> Rule<'_>
pub fn rule(&self, rule_idx: usize) -> Rule<'_>
Return the transition rule at the given index.
Provides O(1) indexed access to a borrowed view of a rule; the children
slice is not copied. The index must be less than Self::num_rules;
passing an out-of-bounds index panics. Rule order matches the order
produced by Self::rules.
Source§impl Explicit
impl Explicit
Sourcepub fn sorted_language(&self) -> SortedLanguageIterator<'_> ⓘ
pub fn sorted_language(&self) -> SortedLanguageIterator<'_> ⓘ
Iterate over accepted trees in descending rule-weight product order.
Source§impl Explicit
impl Explicit
Sourcepub fn viterbi(&self) -> Option<ViterbiTree>
pub fn viterbi(&self) -> Option<ViterbiTree>
Compute the highest-weighted accepted tree.
This is a direct one-best dynamic program for acyclic parse charts. It deliberately avoids the k-best sorted-language machinery when callers only need the best derivation. Cyclic dependencies on the active DFS path are ignored: for PCFG-style rule weights below one, traversing a cycle cannot improve a finite derivation. Direct self-loops are skipped for the same reason, matching Alto’s convention.
Sourcepub fn viterbi_with<S: WeightScorer>(&self, scorer: &S) -> Option<ViterbiTree>
pub fn viterbi_with<S: WeightScorer>(&self, scorer: &S) -> Option<ViterbiTree>
Compute the highest-scoring accepted tree under scorer.
Trait Implementations§
Source§impl BottomUpTa for Explicit
impl BottomUpTa for Explicit
Source§impl CondensedTa for Explicit
impl CondensedTa for Explicit
Source§fn condensed_rules(&self, out: &mut dyn FnMut(&[StateId], &SymbolSet, StateId))
fn condensed_rules(&self, out: &mut dyn FnMut(&[StateId], &SymbolSet, StateId))
(children, result) pair, reporting the set of
symbols that have that shape. Read more