6 #include <boost/range/algorithm/sort.hpp>
9 #include <vcsn/dyn/fwd.hh>
27 template <Automaton Aut>
45 using super_t::super_t;
57 "me=$(basename \"$0\")\n"
58 "medir=$(mktemp -d \"/tmp/$me.XXXXXX\") || exit 1\n"
62 "arc_type=" << arc_type <<
"\n"
70 "cat >$medir/transitions.fsm <<\\EOFSM";
85 " --arc_type=$arc_type \\\n"
86 " --keep_isymbols --isymbols=" << isymbols_ <<
" \\\n"
87 " --keep_osymbols --osymbols=" <<
osymbols_ <<
" \\\n"
88 " $medir/transitions.fsm \"$@\"\n"
105 {
"zmin",
"standard"},
106 {
"rmin",
"standard"},
107 {
"nmin",
"standard"},
114 template <
typename LS>
117 if (ls.is_special(l))
124 template <
typename Label>
131 template <
typename Label>
151 if (
aut_->dst_of(t) !=
aut_->post())
159 if (
ws_.show_one() || !
ws_.is_one(
aut_->weight_of(t)))
175 || !
ws_.is_one(
aut_->weight_of(inis.front())))
184 std::vector<state_t> states(std::begin(
aut_->states()),
185 std::end(
aut_->states()));
189 return (std::forward_as_tuple(!
aut_->is_initial(l), l)
190 < std::forward_as_tuple(!
aut_->is_initial(r),
r));
214 template <
typename LabelSet,
typename Labels,
typename GetLabel>
216 -> std::enable_if_t<has_generators_mem_fn<LabelSet>{}>
218 for (
auto l : ls.generators())
219 labels.insert(get_label(ls.value(l)));
225 template <
typename LabelSet,
typename Labels,
typename GetLabel>
227 -> std::enable_if_t<!has_generators_mem_fn<LabelSet>{}>
254 template <
typename LabelSet,
typename GetLabel>
255 void print_symbols_(
const std::string& name,
260 using labelset_t = LabelSet;
261 using label_t =
typename labelset_t::value_t;
263 auto labels = std::set<label_t, vcsn::less<labelset_t>>{};
269 labels.insert(get_label(
aut_->label_of(t)));
274 "cat >" << name <<
" <<\\EOFSM\n"
277 for (
const auto& l: labels)
281 os_ <<
'\t' << ++num <<
'\n';
291 print_symbols_impl_(std::false_type)
293 print_symbols_(isymbols_,
301 print_symbols_impl_(std::true_type)
303 print_symbols_(isymbols_,
304 ls_.template set<0>(),
305 [](
const label_t& l) { return std::get<0>(l); });
307 ls_.template set<1>(),
308 [](
const label_t& l) { return std::get<1>(l); });
318 const char* isymbols_ =
330 template <Automaton Aut>
332 efsm(
const Aut& aut, std::ostream&
out = std::cout)
const char * osymbols_
File name for output tape symbols.
state_t_of< automaton_t > state_t
auto transitions(const Aut &aut) -> decltype(all_transitions(aut, is_special_t< Aut >
All the transition indexes between visible states.
Print as is. For instance, don't try to escape labels.
auto add_alphabet_(const LabelSet &, Labels &, GetLabel) -> std::enable_if_t<!has_generators_mem_fn< LabelSet >
Fill ls with the letters.
Print automaton to EFSM format, based on FSM format.
void operator()()
Actually output aut_ on os_.
std::ostream & efsm(const Aut &aut, std::ostream &out=std::cout)
Print automaton to EFSM format, based on FSM format.
void print_label_(const Label &l, std::true_type) const
Two-tape automaton.
void print_label_(const LS &ls, const typename LS::value_t &l) const
transition_t_of< automaton_t > transition_t
std::ostream & os_
Output stream.
auto final_transitions(const Aut &aut) -> decltype(aut->all_in(aut->post()))
Indexes of transitions from (visible) final states.
weightset_mixin< detail::r_impl > r
Provide a variadic mul on top of a binary mul(), and one().
const is_transducer_t is_transducer_
size_t states_size(const Aut &aut)
The largest state number, plus one.
auto initial_transitions(const Aut &aut) -> decltype(aut->all_out(aut->pre()))
Indexes of transitions to (visible) initial states.
void print_state_(const state_t s)
Output transitions, sorted lexicographically on (Label, Dest).
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
std::string arc_type_() const
The OpenFST name that corresponds to our weightset.
typename super_t::label_t label_t
Factor common bits in automaton formatting.
void print_label_(const Label &l, std::false_type) const
Acceptor.
void print_transition_(const transition_t t) const override
Output the transition t.
automaton_t aut_
The automaton we have to output.
auto map(const std::tuple< Ts... > &ts, Fun f) -> decltype(map_tuple_(f, ts, make_index_sequence< sizeof...(Ts)>()))
Map a function on a tuple, return tuple of the results.
A mapping from strings to Values.
void print_transitions_()
Output all the transitions, and final states.
auto add_alphabet_(const LabelSet &ls, Labels &labels, GetLabel get_label) -> std::enable_if_t< has_generators_mem_fn< LabelSet >
Fill labels with the gensets of ls.
auto sort(const Aut &a) -> permutation_automaton< Aut >
const weightset_t & ws_
Short-hand to the weightset.
label_t_of< automaton_t > label_t
const labelset_t_of< automaton_t > & ls_
Short-hand to the labelset.