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 using Ilabelset_t =
typename labelset_t::template valueset_t<I>;
87 const labelset_t& in_labelset=*tdc->context().labelset();
97 template <
typename Tdc,
unsigned I,
typename L>
115 const labelset_t& in_labelset=*tdc->context().labelset();
120 std::unordered_map<state_t,state_t> state_map;
121 auto epsilon = ret_labelset.one();
122 for(
auto s : tdc->states()) {
123 state_map[s]=ret->add_state();
125 state_map[ret->pre()]=tdc->pre();
126 state_map[ret->post()]=tdc->post();
127 for(
auto tr: tdc->all_transitions()) {
129 const auto& w=std::get<I>(l);
132 else if (w.length()==1)
135 state_t dst=state_map[tdc->dst_of(tr)];
136 for(
unsigned i=w.length()-1; i>0;i--) {
138 std::get<I>(epsilon)=w[i];
139 ret->new_transition(src, dst, epsilon);
146 auto sg_history = std::make_shared<single_history<transducer_t>>(tdc);
147 for(
auto p : state_map) {
148 sg_history->add_state(p.second,p.first);
149 if(tdc->has_name(p.first)) {
150 ret->set_state_name(p.second, tdc->get_state_name(p.first));
153 ret->set_history(sg_history);
160 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:161
void copy_into(const AutIn &in, AutOut &out, Pred keep_state, bool keep_history=true, bool transpose=false)
Copy an automaton.
Definition: copy.hh:144
auto get_nullableset(const L &labelset) -> typename labelset_trait< L >::nullable_t
Definition: traits.hh:246
auto get_letterset(const L &labelset) -> typename labelset_trait< L >::letterset_t
Definition: traits.hh:225
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
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
Definition: mutable_automaton.hh:915
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:100
typename labelset_trait< letterset_t >::nullable_t nletterset_t
Definition: letterize_tape.hh:104
static ret_transducer_t tdc_letterize(const transducer_t &tdc, bool keep_history)
Definition: letterize_tape.hh:114
typename replace_in_tupleset< nullable_labelset_t, I, nletterset_t >::type ret_labelset_t
Definition: letterize_tape.hh:109
typename map_nullable< labelset_t >::type nullable_labelset_t
Definition: letterize_tape.hh:106
typename labelset_trait< Ilabelset_t >::letterset_t letterset_t
Definition: letterize_tape.hh:103
mutable_automaton< ret_context_t > ret_transducer_t
Definition: letterize_tape.hh:111
weightset_t_of< Tdc > weightset_t
Definition: letterize_tape.hh:101
typename nullable_labelset_t::value_t nullable_label_t
Definition: letterize_tape.hh:107
Tdc transducer_t
Definition: letterize_tape.hh:99
typename labelset_t::template valueset_t< I > Ilabelset_t
Definition: letterize_tape.hh:102
typename ret_labelset_t::value_t ret_label_t
Definition: letterize_tape.hh:112
Definition: letterize_tape.hh:71
typename nullable_labelset_t::value_t nullable_label_t
Definition: letterize_tape.hh:79
typename labelset_trait< Ilabelset_t >::letterset_t letterset_t
Definition: letterize_tape.hh:75
static ret_transducer_t tdc_letterize(const Tdc &tdc, bool keep_history)
Definition: letterize_tape.hh:86
typename map_nullable< labelset_t >::type nullable_labelset_t
Definition: letterize_tape.hh:78
weightset_t_of< Tdc > weightset_t
Definition: letterize_tape.hh:73
mutable_automaton< ret_context_t > ret_transducer_t
Definition: letterize_tape.hh:83
typename labelset_trait< letterset_t >::nullable_t nletterset_t
Definition: letterize_tape.hh:76
labelset_t_of< Tdc > labelset_t
Definition: letterize_tape.hh:72
typename ret_labelset_t::value_t ret_label_t
Definition: letterize_tape.hh:84
typename labelset_t::template valueset_t< I > Ilabelset_t
Definition: letterize_tape.hh:74
typename replace_in_tupleset< nullable_labelset_t, I, nletterset_t >::type ret_labelset_t
Definition: letterize_tape.hh:81
L nullable_t
Definition: traits.hh:35
L letterset_t
Definition: traits.hh:37