Awali
Another Weighted Automata library
transducer.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 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:
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
An automaton_t is essentially a shared pointer to an abstract_automaton_t, but also contains static f...
Definition: automaton.hh:93
weightset_description weightset(const std::string &k)
std::ostream & json(automaton_t aut, std::ostream &out)
unsigned transition_t
Type representing automata transitions; currently simply identifiers of type unsigned,...
Definition: typedefs.hh:33
unsigned state_t
Type representing automata states; currently simply identifiers of type unsigned, but this might chan...
Definition: typedefs.hh:28
Main namespace of Awali.
Definition: ato.hh:22
Structure used to erase the type of labels/weights at the dyn layer.
Definition: any.hh:59
Definition: transducer.hh:30
void del_transition(state_t src, state_t dst, const std::vector< std::string > &labels)
transition_t set_transition(state_t src, state_t dst, const std::vector< std::string > &labels)
std::vector< transition_t > out(state_t s, const std::vector< std::string > &label)
transducer_t(std::istream &json)
transition_t get_transition(state_t src, state_t dst, const std::vector< std::string > &labels)
transition_t set_transition(state_t src, state_t dst, const std::vector< std::string > &labels, weight_t w)
bool has_transition(state_t src, state_t dst, const std::vector< std::string > &labels)
static transducer_t from(std::vector< std::string > alphabets, std::string weightset="B")
weight_t add_transition(state_t src, state_t dst, const std::vector< std::string > &labels)
std::vector< transition_t > in(state_t s, const std::vector< std::string > &label)
std::vector< state_t > predecessors(state_t s, const std::vector< std::string > &label)
transducer_t(const automaton_t &a)
std::vector< state_t > successors(state_t s, const std::vector< std::string > &label)
weight_t add_transition(state_t src, state_t dst, const std::vector< std::string > &labels, weight_t w)
automaton_t operator->()
std::vector< std::string > label_of(transition_t tr)
std::vector< std::vector< char > > alphabets()