17 #ifndef AWALI_STTC_WAUTOMATON_HH
18 #define AWALI_STTC_WAUTOMATON_HH
46 mutable_automaton<context<ctx::lal_char,T>>
49 return make_shared_ptr<mutable_automaton<context<ctx::lal_char,T>>>
57 mutable_automaton<context<ctx::lal_char,b>>
60 return make_automaton<b>(letters);
64 context<ctx::lal_char,T>
69 context<ctx::lal_char,b>
92 mutable_automaton<context<ctx::lan_char,T>>
95 return make_shared_ptr<mutable_automaton<context<ctx::lan_char,T>>>
103 mutable_automaton<context<ctx::lan_char,b>>
106 return make_automaton_with_epsilon<b>(letters);
110 mutable_automaton<context<ctx::lat<ctx::lan_char,ctx::lan_char>,T>>
113 return make_shared_ptr<mutable_automaton<context<ctx::lat<ctx::lan_char,ctx::lan_char>,T>>>
117 mutable_automaton<context<ctx::lat<ctx::lan_char,ctx::lan_char>,b>>
118 make_transducer(
const std::set<char>& letterA,
const std::set<char>& letterB)
120 return make_transducer<b>(letterA, letterB);
124 mutable_automaton<context<ctx::lal_char,T>>
127 if(!p->has_child(
"kind") || p->at(
"kind")->to_string() !=
"Automaton")
128 throw std::runtime_error(
"json: Automaton");
129 if(!p->has_child(
"context"))
130 throw std::runtime_error(
"No context in Automaton description");
135 throw std::runtime_error(
"Not a letter automaton");
137 throw std::runtime_error(
"Epsilon transitions not supported by this function");
139 for(
auto jv : *jl->
at(
"alphabet")->
array())
142 if(p->has_child(
"metadata"))
148 mutable_automaton<context<ctx::lan_char,T>>
151 if(!p->has_child(
"kind") || p->at(
"kind")->to_string() !=
"Automaton")
152 throw std::runtime_error(
"json: Automaton");
153 if(!p->has_child(
"context"))
154 throw std::runtime_error(
"No context in Automaton description");
159 throw std::runtime_error(
"Not a letter automaton");
161 for(
auto jv : *jl->
at(
"alphabet")->
array())
162 const_cast<ctx::lan_char::genset_t&
>(ctx.labelset()->genset()).add_letter(jv->to_string()[0]);
164 if(p->has_child(
"metadata"))
169 mutable_automaton<context<ctx::lal_char,b>>
171 return load_automaton<b>(is);
175 ratexpset_of<context<ctx::lal_char, T>>
183 ratexpset_of<context<ctx::lal_char, b>>
185 return make_ratexpset<b>();
189 ratexpset_of<context<ctx::lat<ctx::lan_char,ctx::lan_char>, T>>
197 ratexpset_of<context<ctx::lat<ctx::lan_char,ctx::lan_char>, b>>
199 return make_tdc_ratexpset<b>();
203 template<
typename RATEXPSET>
205 make_ratexp(RATEXPSET& ratset,
const std::string& exp) ->
typename RATEXPSET::ratexp_t
207 return parse_exp(ratset, exp,
true,
false);
210 template<
typename AUTOMATON>
215 return ratset_t(
get_rat_context(aut->context()),ratset_t::identities_t::trivial);
218 template <
typename Automaton,
unsigned version = version::fsm_json>
226 template <
typename RatExpSet,
unsigned version = version::fsm_json>
228 const typename RatExpSet::ratexp_t& e,
virtual std::string to_string() const
Coerces this node_t to an std::string.
Definition: node.hh:331
virtual array_t const * array() const
Casts this node to array_t.
Definition: node.hh:207
virtual bool has_child(std::string const &key) const override
Definition: node.hh:380
virtual node_t * at(std::string const &key) override
carries the algebraic settings of automata
Definition: context.hh:40
Implementation of labels are letters.
Definition: letterset.hh:43
GenSet genset_t
Definition: letterset.hh:45
Implementation of labels are nullables (letter or empty).
Definition: nullableset.hh:189
typename helper_t::value_t value_t
Definition: nullableset.hh:197
static constexpr ATTRIBUTE_PURE value_t one()
Definition: nullableset.hh:257
static ATTRIBUTE_PURE bool is_one(value_t l)
Definition: nullableset.hh:264
A ValueSet which is a Cartesian product of ValueSets.
Definition: tupleset.hh:80
json_ast_t empty()
Builds an empty json_ast_t.
Definition: json_ast.hh:33
json_ast_t from(std::istream &i)
Builds a json_ast_t from an input stream.
letterset< set_alphabet< char_letters > > lal_char
Definition: lal_char.hh:28
mutable_automaton< context< ctx::lan_char, T > > load_automaton_with_epsilon(std::istream &is)
Definition: automaton.hh:149
ctx::lan_char::value_t get_epsilon()
Helper to get the value of epsilon.
Definition: automaton.hh:74
auto make_ratexp(RATEXPSET &ratset, const std::string &exp) -> typename RATEXPSET::ratexp_t
Definition: automaton.hh:205
json_ast_t aut_to_ast(Automaton aut, json_ast_t extra_metadata=json_ast::empty(), bool full=false)
Definition: js_print.hh:233
RatExpSet::ratexp_t parse_exp(const RatExpSet &ratexpset, const std::string &s, bool check_complete=true, bool strict_alphabet=true)
parser of rational expressions
Definition: exp_parser.hh:438
mutable_automaton< context< ctx::lan_char, T > > make_automaton_with_epsilon(const std::set< char > &letters)
Build an awali weighted automaton labeled by letters with epsilon transitions.
Definition: automaton.hh:93
mutable_automaton< context< ctx::lal_char, T > > make_automaton(const std::set< char > &letters)
Build an awali weighted automaton labeled by letters.
Definition: automaton.hh:47
mutable_automaton< context< ctx::lal_char, T > > load_automaton(std::istream &is)
Definition: automaton.hh:125
auto get_ratexpset(AUTOMATON &aut) -> ratexpset_of< context_t_of< AUTOMATON >>
Definition: automaton.hh:212
mutable_automaton< context< ctx::lat< ctx::lan_char, ctx::lan_char >, T > > make_transducer(const std::set< char > &letterA, const std::set< char > &letterB)
Definition: automaton.hh:111
mutable_automaton< Context > js_parse_aut_content(const Context &context, json::object_t const *p)
Definition: js_parser.hh:104
json_ast_t ratexp_to_ast(const RatExpSet &rs, const typename RatExpSet::ratexp_t &e, json_ast_t extra_metadata=json_ast::empty())
Definition: js_print.hh:338
bool is_epsilon(ctx::lan_char::value_t v)
Definition: automaton.hh:78
context< ctx::lal_char, T > make_context(const std::set< char > &letters)
Definition: automaton.hh:65
std::ostream & js_print(Automaton aut, std::ostream &o, bool full=false, json_ast_t extra_metadata=json_ast::empty())
Definition: automaton.hh:219
void js_add_metadata(Aut &aut, json::object_t *p)
Definition: js_parser.hh:164
ratexpset_of< context< ctx::lat< ctx::lan_char, ctx::lan_char >, T > > make_tdc_ratexpset()
Definition: automaton.hh:190
ratexpset_of< context< ctx::lal_char, T > > make_ratexpset()
Definition: automaton.hh:176
ratexp_context_of< Context > get_rat_context(const Context &ctx)
Definition: traits.hh:295
static const std::string full
Completely version of Awali as a std::string.
Definition: version.hh:42
Main namespace of Awali.
Definition: ato.hh:22
std::shared_ptr< json::object_t > json_ast_t
Definition: json_ast.hh:27
std::ostream & put(json_ast_t tree, std::ostream &out)
Provide a variadic mul on top of a binary mul(), and one().
Definition: weightset.hh:38