Vcsn  2.2
Be Rational
vcsn::lazy_automaton_editor Class Reference

Build an automaton with unknown context. More...

#include <edit-automaton.hh>

Collaboration diagram for vcsn::lazy_automaton_editor:

Public Types

enum  labelset_type { labelset_type::empty, labelset_type::lal, labelset_type::lan, labelset_type::law }
 Labelset types, increasing generality. More...
 
enum  weightset_type { weightset_type::logarithmic, weightset_type::numerical, weightset_type::tropical }
 Weightset types. More...
 
using string_t = automaton_editor::string_t
 A hash-cons'ed string type. More...
 

Public Member Functions

void add_initial (string_t s, string_t w=string_t{})
 Add s as an initial state. More...
 
void add_final (string_t s, string_t w=string_t{})
 Add s as a final state. More...
 
void add_transition (string_t src, string_t dst, string_t lbl, string_t w=string_t{})
 Add an acceptor transition from src to dst, labeled by lbl. More...
 
void add_transition (string_t src, string_t dst, string_t lbl1, string_t lbl2, string_t w)
 Add a transducer transition from src to dst, labeled by (lbl1, lbl2). More...
 
std::string result_context () const
 Return the context that was inferred. More...
 
dyn::automaton result (const std::string &ctx={})
 Return the built automaton. More...
 
bool open (bool o)
 Whether unknown letters should be added, or rejected. More...
 
void reset ()
 Get ready to build another automaton. More...
 
void weightset (weightset_type t)
 Specify the weightset type. More...
 

Private Types

using transition_t = std::tuple< string_t, string_t, string_t, string_t >
 The collected transitions: (Source, Destination, Label, Weight). More...
 

Private Member Functions

void register_weight_ (string_t w)
 Record that this weight was seen. More...
 

Private Attributes

std::vector< transition_ttransitions_
 
std::vector< std::pair< string_t, string_t > > initial_states_
 The collected initial states: (State, Weight). More...
 
std::vector< std::pair< string_t, string_t > > final_states_
 The collected final states: (State, Weight). More...
 
labelset_type input_type_ = labelset_type::empty
 Labelset type for input tape. More...
 
labelset_type output_type_ = labelset_type::empty
 Labelset type for output tape. More...
 
bool weighted_ = false
 Whether we saw a non-empty weight. More...
 
bool real_ = false
 Whether we saw a period in a the weight. More...
 
bool open_ = false
 Whether the labelset is open. More...
 
weightset_type weightset_type_ = weightset_type::numerical
 The weightset scale. More...
 

Detailed Description

Build an automaton with unknown context.

Record the transitions, initial and final states as strings, and once the automata completed, decide what is its context, and build a genuine automaton.

Definition at line 268 of file edit-automaton.hh.

Member Typedef Documentation

A hash-cons'ed string type.

Definition at line 272 of file edit-automaton.hh.

The collected transitions: (Source, Destination, Label, Weight).

Definition at line 322 of file edit-automaton.hh.

Member Enumeration Documentation

Labelset types, increasing generality.

Enumerator
empty 
lal 
lan 
law 

Definition at line 275 of file edit-automaton.hh.

Weightset types.

Enumerator
logarithmic 
numerical 
tropical 

Definition at line 278 of file edit-automaton.hh.

Member Function Documentation

void vcsn::lazy_automaton_editor::add_final ( string_t  s,
string_t  w = string_t{} 
)

Add s as a final state.

Definition at line 84 of file edit-automaton.cc.

References final_states_, and register_weight_().

Referenced by vcsn::dyn::read_fado().

Here is the call graph for this function:

void vcsn::lazy_automaton_editor::add_initial ( string_t  s,
string_t  w = string_t{} 
)

Add s as an initial state.

Definition at line 77 of file edit-automaton.cc.

References initial_states_, and register_weight_().

Referenced by vcsn::dyn::read_fado().

Here is the call graph for this function:

void vcsn::lazy_automaton_editor::add_transition ( string_t  src,
string_t  dst,
string_t  lbl,
string_t  w = string_t{} 
)

Add an acceptor transition from src to dst, labeled by lbl.

Add transitions from src to dst, labeled by entry.

Definition at line 117 of file edit-automaton.cc.

Referenced by vcsn::dyn::read_fado().

void vcsn::lazy_automaton_editor::add_transition ( string_t  src,
string_t  dst,
string_t  lbl1,
string_t  lbl2,
string_t  w 
)

Add a transducer transition from src to dst, labeled by (lbl1, lbl2).

Add transitions from src to dst, labeled by entry.

Definition at line 94 of file edit-automaton.cc.

References input_type_, output_type_, vcsn::detail::quote(), register_weight_(), transitions_, and vcsn::dyn::type().

Here is the call graph for this function:

bool vcsn::lazy_automaton_editor::open ( bool  o)

Whether unknown letters should be added, or rejected.

Parameters
owhether to accept
Returns
the previous status.

Definition at line 126 of file edit-automaton.cc.

References open_.

Referenced by vcsn::dyn::read_efsm(), and vcsn::dyn::read_fado().

void vcsn::lazy_automaton_editor::register_weight_ ( string_t  w)
private

Record that this weight was seen.

Examine it to see if it's a float etc.

Definition at line 65 of file edit-automaton.cc.

References real_, and weighted_.

Referenced by add_final(), add_initial(), and add_transition().

void vcsn::lazy_automaton_editor::reset ( )

Get ready to build another automaton.

Definition at line 133 of file edit-automaton.cc.

References final_states_, initial_states_, and transitions_.

dyn::automaton vcsn::lazy_automaton_editor::result ( const std::string &  ctx = {})

Return the built automaton.

Parameters
ctxthe context to load this automaton. Defaults to the result_context().

Definition at line 170 of file edit-automaton.cc.

References vcsn::rat::ctx(), final_states_, initial_states_, vcsn::dyn::make_automaton_editor(), vcsn::dyn::make_context(), open_, result_context(), and transitions_.

Referenced by vcsn::dyn::read_fado().

Here is the call graph for this function:

std::string vcsn::lazy_automaton_editor::result_context ( ) const

Return the context that was inferred.

Definition at line 140 of file edit-automaton.cc.

References empty, input_type_, lal, logarithmic, numerical, output_type_, real_, vcsn::to_string(), tropical, weighted_, and weightset_type_.

Referenced by result().

Here is the call graph for this function:

void vcsn::lazy_automaton_editor::weightset ( weightset_type  t)
inline

Specify the weightset type.

Definition at line 314 of file edit-automaton.hh.

References weightset_type_.

Member Data Documentation

std::vector<std::pair<string_t, string_t> > vcsn::lazy_automaton_editor::final_states_
private

The collected final states: (State, Weight).

Definition at line 327 of file edit-automaton.hh.

Referenced by add_final(), reset(), and result().

std::vector<std::pair<string_t, string_t> > vcsn::lazy_automaton_editor::initial_states_
private

The collected initial states: (State, Weight).

Definition at line 325 of file edit-automaton.hh.

Referenced by add_initial(), reset(), and result().

labelset_type vcsn::lazy_automaton_editor::input_type_ = labelset_type::empty
private

Labelset type for input tape.

Definition at line 329 of file edit-automaton.hh.

Referenced by add_transition(), and result_context().

bool vcsn::lazy_automaton_editor::open_ = false
private

Whether the labelset is open.

Definition at line 337 of file edit-automaton.hh.

Referenced by open(), and result().

labelset_type vcsn::lazy_automaton_editor::output_type_ = labelset_type::empty
private

Labelset type for output tape.

Definition at line 331 of file edit-automaton.hh.

Referenced by add_transition(), and result_context().

bool vcsn::lazy_automaton_editor::real_ = false
private

Whether we saw a period in a the weight.

Definition at line 335 of file edit-automaton.hh.

Referenced by register_weight_(), and result_context().

std::vector<transition_t> vcsn::lazy_automaton_editor::transitions_
private

Definition at line 323 of file edit-automaton.hh.

Referenced by add_transition(), reset(), and result().

bool vcsn::lazy_automaton_editor::weighted_ = false
private

Whether we saw a non-empty weight.

Definition at line 333 of file edit-automaton.hh.

Referenced by register_weight_(), and result_context().

weightset_type vcsn::lazy_automaton_editor::weightset_type_ = weightset_type::numerical
private

The weightset scale.

Definition at line 339 of file edit-automaton.hh.

Referenced by result_context(), and weightset().


The documentation for this class was generated from the following files: