13 #ifndef _FOMA_TRANSDUCER_H_
14 #define _FOMA_TRANSDUCER_H_
18 #include "HfstExtractStrings.h"
25 #include "back-ends/foma/fomalib.h"
36 #include "../FormatSpecifiers.h"
43 namespace implementations
47 using std::ostringstream;
54 void skip_identifier_version_3_0(
void);
55 void skip_hfst_header(
void);
57 FomaInputStream(
void);
58 FomaInputStream(
const std::string &filename);
64 void ignore(
unsigned int);
65 fsm * read_transducer();
68 short stream_get_short();
69 void stream_unget(
char c);
71 static bool is_fst(FILE * f);
72 static bool is_fst(std::istream &s);
75 class FomaOutputStream
82 FomaOutputStream(
void);
83 FomaOutputStream(
const std::string &filename);
85 void write(
const char &c);
86 void write_transducer(fsm * transducer);
92 static fsm * create_empty_transducer(
void);
93 static fsm * create_epsilon_transducer(
void);
95 static fsm * define_transducer
97 static fsm * define_transducer(
const std::vector<StringPairSet> &spsv);
98 static fsm * define_transducer
99 (
const std::string &symbol);
100 static fsm * define_transducer
101 (
const std::string &isymbol,
const std::string &osymbol);
102 static fsm * copy(fsm * t);
103 static fsm * determinize(fsm * t);
104 static fsm * minimize(fsm * t);
105 static fsm * remove_epsilons(fsm * t);
106 static fsm * repeat_star(fsm * t);
107 static fsm * repeat_plus(fsm * t);
108 static fsm * repeat_n(fsm * t,
unsigned int n);
109 static fsm * repeat_le_n(fsm * t,
unsigned int n);
110 static fsm * optionalize(fsm * t);
111 static fsm * invert(fsm * t);
112 static fsm * reverse(fsm * t);
113 static fsm * extract_input_language(fsm * t);
114 static fsm * extract_output_language(fsm * t);
116 static fsm * insert_freely(fsm * t,
const StringPair &symbol_pair);
118 static bool are_equivalent(fsm *t1, fsm *t2);
119 static bool is_cyclic(fsm * t);
121 static fsm * substitute
124 static fsm * compose(fsm * t1,
126 static fsm * concatenate(fsm * t1,
128 static fsm * disjunct(fsm * t1,
130 static fsm * intersect(fsm * t1,
132 static fsm * subtract(fsm * t1,
135 static void extract_paths(fsm * t, hfst::ExtractStringsCb& callback,
136 int cycles=-1, FdTable<int>* fd=NULL,
137 bool filter_fd=
false);
138 static void extract_random_paths
141 static FdTable<int>* get_flag_diacritics(fsm * t);
143 static unsigned int get_biggest_symbol_number(fsm * t);
144 static StringVector get_symbol_vector(fsm * t);
145 static std::map<std::string, unsigned int> get_symbol_map(fsm * t);
147 static void insert_to_alphabet(fsm *t,
const std::string &symbol);
148 static void remove_from_alphabet(fsm *t,
const std::string &symbol);
149 static StringSet get_alphabet(fsm *t);
150 static unsigned int get_symbol_number(fsm *t,
151 const std::string &symbol);
153 static void harmonize(fsm *net1, fsm *net2);
155 static fsm * read_net(FILE * file);
156 static int write_net(fsm * net, FILE * file);
158 static void delete_foma(fsm * net);
159 static void print_test(fsm * t);
161 static fsm * read_lexc(
const std::string &filename,
bool verbose);
163 static unsigned int number_of_states(fsm * net);
164 static unsigned int number_of_arcs(fsm * net);
166 static fsm * eliminate_flags(fsm * t);
167 static fsm * eliminate_flag(fsm * t,
const std::string & flag);
std::pair< String, String > StringPair
A symbol pair in a transition.
Definition: HfstSymbolDefs.h:71
std::string String
A UTF-8 symbol in a transition.
Definition: HfstSymbolDefs.h:60
std::vector< std::pair< std::string, std::string > > StringPairVector
A vector of string pairs.
Definition: HfstDataTypes.h:106
Class declarations for flag diacritic handling.
std::set< HfstTwoLevelPath > HfstTwoLevelPaths
A set of two-level weighted paths.
Definition: HfstDataTypes.h:110
std::set< StringPair > StringPairSet
A set of symbol pairs used in substituting symbol pairs and in rule functions.
Definition: HfstSymbolDefs.h:83
Typedefs and functions for symbols, symbol pairs and sets of symbols.