10 #ifndef _XFSM_TRANSDUCER_H_
11 #define _XFSM_TRANSDUCER_H_
15 #include "HfstExtractStrings.h"
21 #include "xfsm/xfsm_api.h"
28 #include "../FormatSpecifiers.h"
35 namespace implementations
53 XfsmInputStream(
void);
55 XfsmInputStream(
const std::string &filename);
68 NETptr read_transducer();
72 class XfsmOutputStream
81 XfsmOutputStream(
void);
83 XfsmOutputStream(
const std::string &filename);
89 void write_transducer(NETptr transducer);
92 class XfsmTransducer {
94 static bool minimize_even_if_already_minimal_;
97 static void initialize_xfsm();
98 static NETptr create_xfsm_unknown_to_unknown_transducer();
99 static NETptr create_xfsm_identity_to_identity_transducer();
100 static id_type hfst_symbol_to_xfsm_symbol(
const std::string & symbol);
101 static std::string xfsm_symbol_to_hfst_symbol(id_type
id);
102 static void label_id_to_symbol_pair(id_type label_id, std::string & isymbol, std::string & osymbol);
103 static id_type symbol_pair_to_label_id(
const std::string & isymbol,
const std::string & osymbol);
105 static NETptr create_empty_transducer(
void);
106 static NETptr create_epsilon_transducer(
void);
108 static NETptr define_transducer
110 static NETptr define_transducer(
const std::vector<StringPairSet> &spsv);
111 static NETptr define_transducer
112 (
const std::string &symbol);
113 static NETptr define_transducer
114 (
const std::string &isymbol,
const std::string &osymbol);
115 static NETptr copy(NETptr t);
116 static NETptr minimize(NETptr t);
118 static NETptr compose(NETptr t1,
const NETptr t2);
119 static NETptr concatenate(NETptr t1,
const NETptr t2);
120 static NETptr disjunct(NETptr t1,
const NETptr t2);
121 static NETptr intersect(NETptr t1,
const NETptr t2);
122 static NETptr subtract(NETptr t1,
const NETptr t2);
124 static bool are_equivalent(NETptr t1, NETptr t2);
125 static bool is_cyclic(NETptr t);
126 static unsigned int number_of_states(NETptr t);
127 static unsigned int number_of_arcs(NETptr t);
128 static NETptr eliminate_flags_xfsm(NETptr t);
129 static NETptr eliminate_flag_xfsm(NETptr t,
const std::string & flag);
131 static NETptr repeat_star(NETptr t);
132 static NETptr repeat_plus(NETptr t);
133 static NETptr repeat_n(NETptr t,
unsigned int n);
134 static NETptr repeat_le_n(NETptr t,
unsigned int n);
135 static NETptr repeat_n_plus(NETptr t,
unsigned int n);
136 static NETptr repeat_n_to_k(NETptr t,
unsigned int n,
unsigned int k);
138 static NETptr optionalize(NETptr t);
139 static NETptr invert(NETptr t);
140 static NETptr reverse(NETptr t);
141 static NETptr extract_input_language(NETptr t);
142 static NETptr extract_output_language(NETptr t);
144 static NETptr insert_freely(NETptr t,
const NETptr ins);
146 static StringSet get_alphabet(
const NETptr t);
147 static void add_symbol_to_alphabet(NETptr t,
const std::string & symbol);
148 static void add_symbols_to_alphabet(NETptr t,
const StringSet & symbols);
149 static void remove_symbols_from_alphabet(NETptr t,
const StringSet & symbols);
152 static void set_minimize_even_if_already_minimal(
bool value);
153 static void set_compose_flag_as_special(
bool value);
155 static void write_in_att_format(NETptr t,
const char * filename);
156 static void write_in_prolog_format(NETptr t,
const char * filename);
157 static NETptr prolog_file_to_xfsm_transducer(
const char * filename);
std::vector< std::pair< std::string, std::string > > StringPairVector
A vector of string pairs.
Definition: HfstDataTypes.h:105
Class declarations for flag diacritic handling.
std::set< StringPair > StringPairSet
A set of symbol pairs used in substituting symbol pairs and in rule functions.
Definition: HfstSymbolDefs.h:82
Typedefs and functions for symbols, symbol pairs and sets of symbols.