Vcsn
2.2
Be Rational
|
Build a trie automaton (prefix-tree-like automaton). More...
#include <trie.hh>
Public Types | |
using | context_t = Context |
using | self_t = trie_builder |
using | automaton_t = mutable_automaton< context_t > |
The type of the result. More... | |
using | work_automaton_t = std::conditional_t< Dir==direction::forward, automaton_t, transpose_automaton< automaton_t >> |
The type of the automaton we work on. More... | |
using | labelset_t = labelset_t_of< context_t > |
The input labelset, free/letterized or not. More... | |
using | letter_t = letter_t_of< context_t > |
using | word_t = word_t_of< context_t > |
using | weightset_t = weightset_t_of< context_t > |
using | weight_t = weight_t_of< context_t > |
using | state_t = state_t_of< automaton_t > |
using | polynomialset_t = word_polynomialset_t< context_t > |
Polynomialset for the input: weighted words. More... | |
using | polynomial_t = typename polynomialset_t::value_t |
using | monomial_t = typename polynomialset_t::monomial_t |
Public Member Functions | |
trie_builder (const context_t &c) | |
void | add (const word_t &l, const weight_t &w=weightset_t::one()) |
Add a monomial. More... | |
void | add (const monomial_t &m) |
Add a monomial. More... | |
void | add (const polynomial_t &p) |
Add a polynomial. More... | |
void | add_words (std::istream &is) |
Add all the words (one per line) in this stream. More... | |
void | add_monomials (std::istream &is) |
Add all the monomials (one per line) in this stream. More... | |
void | add (std::istream &is, const std::string &format) |
Add all the monomials in this stream. More... | |
template<direction D = Dir> | |
auto | result () -> std::enable_if_t< D==direction::forward, automaton_t > |
Get the result for the forward trie. More... | |
template<direction D = Dir> | |
auto | result () -> std::enable_if_t< D==direction::backward, automaton_t > |
Get the result for a backward trie. More... | |
Private Member Functions | |
void | add_ (const word_t &lbl, const weight_t &wgt) |
Add a monomial. More... | |
state_t | next_ (state_t s, letter_t l) |
Follow a transition, possibly creating it. More... | |
Private Attributes | |
work_automaton_t | res_ |
The automaton being built. More... | |
const context_t & | ctx_ = res_->context() |
The context of the automaton: letterized. More... | |
letterized_t< labelset_t >::value_t | padding_ = letterized_t<labelset_t>::one() |
Padding, in case it is needed. More... | |
Build a trie automaton (prefix-tree-like automaton).
Context | the context of the mutable_automaton to build. It is typically a letterset, even though we feed it with words. |
Dir | if forward build a trie (single initial state) otherwise (backward ) build a reversed trie (single final state, but many initial states). |
using vcsn::detail::trie_builder< Context, Dir >::automaton_t = mutable_automaton<context_t> |
using vcsn::detail::trie_builder< Context, Dir >::context_t = Context |
using vcsn::detail::trie_builder< Context, Dir >::labelset_t = labelset_t_of<context_t> |
using vcsn::detail::trie_builder< Context, Dir >::letter_t = letter_t_of<context_t> |
using vcsn::detail::trie_builder< Context, Dir >::monomial_t = typename polynomialset_t::monomial_t |
using vcsn::detail::trie_builder< Context, Dir >::polynomial_t = typename polynomialset_t::value_t |
using vcsn::detail::trie_builder< Context, Dir >::polynomialset_t = word_polynomialset_t<context_t> |
using vcsn::detail::trie_builder< Context, Dir >::self_t = trie_builder |
using vcsn::detail::trie_builder< Context, Dir >::state_t = state_t_of<automaton_t> |
using vcsn::detail::trie_builder< Context, Dir >::weight_t = weight_t_of<context_t> |
using vcsn::detail::trie_builder< Context, Dir >::weightset_t = weightset_t_of<context_t> |
using vcsn::detail::trie_builder< Context, Dir >::word_t = word_t_of<context_t> |
using vcsn::detail::trie_builder< Context, Dir >::work_automaton_t = std::conditional_t<Dir == direction::forward, automaton_t, transpose_automaton<automaton_t>> |
|
inline |
|
inline |
Add a monomial.
l | the word to add. |
w | its associated weight. |
Definition at line 82 of file trie.hh.
References vcsn::detail::trie_builder< Context, Dir >::add_().
Referenced by vcsn::detail::trie_builder< Context, Dir >::add(), vcsn::detail::trie_builder< Context, Dir >::add_monomials(), and vcsn::detail::trie_builder< Context, Dir >::add_words().
|
inline |
Add a monomial.
Definition at line 88 of file trie.hh.
References vcsn::detail::trie_builder< Context, Dir >::add(), vcsn::label_of(), and vcsn::weight_of().
|
inline |
Add a polynomial.
Definition at line 94 of file trie.hh.
References vcsn::detail::trie_builder< Context, Dir >::add().
|
inline |
Add all the monomials in this stream.
Definition at line 122 of file trie.hh.
References vcsn::detail::trie_builder< Context, Dir >::add_monomials(), vcsn::detail::trie_builder< Context, Dir >::add_words(), is, and vcsn::detail::map().
|
inlineprivate |
Add a monomial.
Take the direction into account (i.e., transpose the word if needed).
lbl | the word to add. |
wgt | its associated weight. |
Definition at line 158 of file trie.hh.
References vcsn::detail::trie_builder< Context, Dir >::ctx_, vcsn::forward, vcsn::detail::trie_builder< Context, Dir >::next_(), vcsn::detail::trie_builder< Context, Dir >::padding_, and vcsn::detail::trie_builder< Context, Dir >::res_.
Referenced by vcsn::detail::trie_builder< Context, Dir >::add().
|
inline |
Add all the monomials (one per line) in this stream.
Definition at line 114 of file trie.hh.
References vcsn::detail::trie_builder< Context, Dir >::add(), vcsn::detail::trie_builder< Context, Dir >::ctx_, and vcsn::detail::make_word_polynomialset().
Referenced by vcsn::detail::trie_builder< Context, Dir >::add().
|
inline |
Add all the words (one per line) in this stream.
Definition at line 101 of file trie.hh.
References vcsn::detail::trie_builder< Context, Dir >::add(), vcsn::conv(), vcsn::detail::trie_builder< Context, Dir >::ctx_, vcsn::detail::make_wordset(), and vcsn::detail::quote().
Referenced by vcsn::detail::trie_builder< Context, Dir >::add().
|
inlineprivate |
Follow a transition, possibly creating it.
Definition at line 174 of file trie.hh.
References vcsn::detail::front(), vcsn::detail::out(), and vcsn::detail::trie_builder< Context, Dir >::res_.
Referenced by vcsn::detail::trie_builder< Context, Dir >::add_().
|
inline |
Get the result for the forward trie.
Definition at line 138 of file trie.hh.
References vcsn::detail::trie_builder< Context, Dir >::res_.
|
inline |
Get the result for a backward trie.
Definition at line 146 of file trie.hh.
References vcsn::detail::trie_builder< Context, Dir >::res_, and vcsn::transpose().
|
private |
The context of the automaton: letterized.
Definition at line 191 of file trie.hh.
Referenced by vcsn::detail::trie_builder< Context, Dir >::add_(), vcsn::detail::trie_builder< Context, Dir >::add_monomials(), and vcsn::detail::trie_builder< Context, Dir >::add_words().
|
private |
Padding, in case it is needed.
Definition at line 194 of file trie.hh.
Referenced by vcsn::detail::trie_builder< Context, Dir >::add_().
|
private |
The automaton being built.
Definition at line 189 of file trie.hh.
Referenced by vcsn::detail::trie_builder< Context, Dir >::add_(), vcsn::detail::trie_builder< Context, Dir >::next_(), and vcsn::detail::trie_builder< Context, Dir >::result().