17 #ifndef AWALI_ALGOS_TDC_LAW_TO_LAN_HH
18 #define AWALI_ALGOS_TDC_LAW_TO_LAN_HH
25 #include<unordered_map>
37 template<
typename Letterset,
typename... T>
59 template <
typename... T,
size_t I,
typename U>
70 template <
typename Tdc,
unsigned I,
typename Labelset>
74 return copy(tdc, keep_history);
78 template <
typename Tdc,
unsigned I,
typename L>
83 using Ilabelset_t =
typename labelset_t::template valueset_t<I>;
96 const labelset_t& in_labelset=*tdc->context().labelset();
101 std::unordered_map<state_t,state_t> state_map;
102 auto epsilon = ret_labelset.one();
103 for(
auto s : tdc->states()) {
104 state_map[s]=ret->add_state();
106 state_map[ret->pre()]=tdc->pre();
107 state_map[ret->post()]=tdc->post();
108 for(
auto tr: tdc->all_transitions()) {
110 const auto& w=std::get<I>(l);
113 else if (w.length()==1)
116 state_t dst=state_map[tdc->dst_of(tr)];
117 for(
unsigned i=w.length()-1; i>0;i--) {
119 std::get<I>(epsilon)=w[i];
120 ret->new_transition(src, dst, epsilon);
127 auto sg_history = std::make_shared<single_history<transducer_t>>(tdc);
128 for(
auto p : state_map)
129 sg_history->add_state(p.second,p.first);
130 ret->set_history(sg_history);
137 template<
unsigned I,
typename Tdc>
carries the algebraic settings of automata
Definition: context.hh:40
context(const context &that)
Definition: context.hh:67
A ValueSet which is a Cartesian product of ValueSets.
Definition: tupleset.hh:80
const valuesets_t & sets() const
The componants valuesets, as a tuple.
Definition: tupleset.hh:152
Implementation of labels are words.
Definition: wordset.hh:35
weightset_description weightset(const std::string &k)
auto tuple_tail(const Tuple &t) -> typename tail_tuple< Tuple >::type
Definition: sub_tuple.hh:96
Definition: letterize_tape.hh:36
Definition: letterize_tape.hh:57
Definition: projection.hh:52
auto letterize_tape(const Tdc &tdc, bool keep_history=true) -> typename internal::tdc_letterizer< Tdc, I, typename labelset_t_of< Tdc >::template valueset_t< I >>::ret_transducer_t
Definition: letterize_tape.hh:138
auto get_nullableset(const L &labelset) -> typename labelset_trait< L >::nullable_t
Definition: traits.hh:195
auto get_letterset(const L &labelset) -> typename labelset_trait< L >::letterset_t
Definition: traits.hh:174
typename internal::labelset_t_of_impl< internal::base_t< ValueSet > >::type labelset_t_of
Helper to retrieve the type of the labelset of a value set.
Definition: traits.hh:76
AutOut copy(const AutIn &input, Pred keep_state, bool keep_history=true, bool transpose=false)
A copy of input keeping only its states that are accepted by keep_state.
Definition: copy.hh:185
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
Definition: mutable_automaton.hh:911
std::shared_ptr< internal::mutable_automaton_impl< Context > > mutable_automaton
Definition: mutable_automaton.hh:45
typename internal::weightset_t_of_impl< internal::base_t< ValueSet > >::type weightset_t_of
Helper to retrieve the type of the weightset of a value set.
Definition: traits.hh:86
Main namespace of Awali.
Definition: ato.hh:22
unsigned state_t
Definition: types.hh:21
static tupleT gettuple(const std::tuple< Letterset, T... > &t)
Definition: letterize_tape.hh:42
typename tuple_to_tupleset< tupleT >::type type
Definition: letterize_tape.hh:40
static type get(const tupleset< Letterset, T... > &ts)
Definition: letterize_tape.hh:44
typename std::cons_tuple< typename labelset_trait< Letterset >::nullable_t, typename map_nullable< tupleset< T... > >::tupleT >::type tupleT
Definition: letterize_tape.hh:39
static type get(const tupleset<> &ts)
Definition: letterize_tape.hh:54
std::tuple<> tupleT
Definition: letterize_tape.hh:50
static tupleT gettuple(const std::tuple<> &t)
Definition: letterize_tape.hh:53
Definition: sub_tuple.hh:144
static auto get(const Tuple &t, const T &x) -> type< Tuple >
Definition: sub_tuple.hh:152
static type get(const tp_t &t, const U &v)
Definition: letterize_tape.hh:65
typename tuple_to_tupleset< typename replace_in_tuple< I, U >::template type< std::tuple< T... > >>::type type
Definition: letterize_tape.hh:62
labelset_t_of< Tdc > labelset_t
Definition: letterize_tape.hh:81
typename labelset_trait< letterset_t >::nullable_t nletterset_t
Definition: letterize_tape.hh:85
static ret_transducer_t tdc_letterize(const transducer_t &tdc, bool keep_history)
Definition: letterize_tape.hh:95
typename replace_in_tupleset< nullable_labelset_t, I, nletterset_t >::type ret_labelset_t
Definition: letterize_tape.hh:90
typename map_nullable< labelset_t >::type nullable_labelset_t
Definition: letterize_tape.hh:87
typename labelset_trait< Ilabelset_t >::letterset_t letterset_t
Definition: letterize_tape.hh:84
mutable_automaton< ret_context_t > ret_transducer_t
Definition: letterize_tape.hh:92
weightset_t_of< Tdc > weightset_t
Definition: letterize_tape.hh:82
typename nullable_labelset_t::value_t nullable_label_t
Definition: letterize_tape.hh:88
Tdc transducer_t
Definition: letterize_tape.hh:80
typename labelset_t::template valueset_t< I > Ilabelset_t
Definition: letterize_tape.hh:83
typename ret_labelset_t::value_t ret_label_t
Definition: letterize_tape.hh:93
Definition: letterize_tape.hh:71
static ret_transducer_t tdc_letterize(const Tdc &tdc, bool keep_history)
Definition: letterize_tape.hh:73
Tdc ret_transducer_t
Definition: letterize_tape.hh:72
L nullable_t
Definition: traits.hh:34
L letterset_t
Definition: traits.hh:36