Awali
Another Weighted Automata library
transducer.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2021 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 /* @file transducer.hh
18  * This files contains the definition of the transducer type for the dynamic library
19  *
20  * It allows direct access to some services which are also accessible through functions
21  */
22 #ifndef DYN_TRANSDUCER_HH
23 #define DYN_TRANSDUCER_HH
24 
26 
27 namespace awali {
28  namespace dyn {
29 
30  struct transducer_t {
31  // A transducer wraps an automaton and may be converted to one
32  private:
33  automaton_t aut_;
34  public:
35  transducer_t(const automaton_t& a);
36  transducer_t(std::istream& json);
37 
38  //For compatibility with the behaviour of automata
40 
41  operator automaton_t();
42 
43  unsigned num_tapes();
44 
46  const std::vector<std::string>& labels);
47 
48  bool has_transition(state_t src, state_t dst,
49  const std::vector<std::string>& labels);
50 
52  const std::vector<std::string>& labels);
53 
55  const std::vector<std::string>& labels, weight_t w);
56 
58  const std::vector<std::string>& labels);
59 
61  const std::vector<std::string>& labels, weight_t w);
62 
63  void del_transition(state_t src, state_t dst,
64  const std::vector<std::string>& labels);
65 
66  std::vector<state_t> successors(state_t s,
67  const std::vector<std::string>& label);
68 
69  std::vector<state_t> predecessors(state_t s,
70  const std::vector<std::string>& label);
71 
72  std::vector<transition_t> in(state_t s,
73  const std::vector<std::string>& label);
74 
75  std::vector<transition_t> out(state_t s,
76  const std::vector<std::string>& label);
77 
78  std::vector<std::string> label_of(transition_t tr);
79 
80  std::vector<std::vector<char>> alphabets();
81 
82  static transducer_t from(std::vector<std::string> alphabets,
83  std::string weightset = "B");
84  };
85 
86  }
87 }//end of ns awali::dyn
88 #endif
awali::dyn::internal::json
std::ostream & json(automaton_t aut, std::ostream &out)
awali
Main namespace of Awali.
Definition: ato.hh:22
awali::dyn::transducer_t::add_transition
weight_t add_transition(state_t src, state_t dst, const std::vector< std::string > &labels)
awali::dyn::transition_t
unsigned transition_t
Type representing automata transitions; currently simply identifiers of type unsigned,...
Definition: typedefs.hh:33
awali::dyn::transducer_t::transducer_t
transducer_t(const automaton_t &a)
awali::dyn::any_t
Structure used to erase the type of labels/weights at the dyn layer.
Definition: any.hh:53
awali::dyn::transducer_t::set_transition
transition_t set_transition(state_t src, state_t dst, const std::vector< std::string > &labels)
awali::dyn::transducer_t::alphabets
std::vector< std::vector< char > > alphabets()
awali::dyn::transducer_t::from
static transducer_t from(std::vector< std::string > alphabets, std::string weightset="B")
awali::dyn::context::weightset
weightset_description weightset(const std::string &k)
awali::dyn::automaton_t
An automaton_t is essentially a shared pointer to an abstract_automaton_t, but also contains static f...
Definition: automaton.hh:93
awali::dyn::transducer_t::in
std::vector< transition_t > in(state_t s, const std::vector< std::string > &label)
awali::dyn::transducer_t::successors
std::vector< state_t > successors(state_t s, const std::vector< std::string > &label)
awali::dyn::transducer_t::out
std::vector< transition_t > out(state_t s, const std::vector< std::string > &label)
automaton.hh
awali::dyn::transducer_t::label_of
std::vector< std::string > label_of(transition_t tr)
awali::dyn::transducer_t::has_transition
bool has_transition(state_t src, state_t dst, const std::vector< std::string > &labels)
awali::dyn::state_t
unsigned state_t
Type representing automata states; currently simply identifiers of type unsigned, but this might chan...
Definition: typedefs.hh:28
awali::dyn::transducer_t::del_transition
void del_transition(state_t src, state_t dst, const std::vector< std::string > &labels)
awali::dyn::transducer_t::operator->
automaton_t operator->()
awali::dyn::transducer_t
Definition: transducer.hh:30
awali::dyn::transducer_t::num_tapes
unsigned num_tapes()
awali::dyn::transducer_t::predecessors
std::vector< state_t > predecessors(state_t s, const std::vector< std::string > &label)
awali::dyn::transducer_t::get_transition
transition_t get_transition(state_t src, state_t dst, const std::vector< std::string > &labels)