13 #ifndef _CONVERT_TRANSDUCER_H_
14 #define _CONVERT_TRANSDUCER_H_
18 #endif // HAVE_CONFIG_H
27 #include "back-ends/openfstwin/src/include/fst/fstlib.h"
29 #include "back-ends/openfst/src/include/fst/fstlib.h"
31 #endif // HAVE_OPENFST
34 #include "back-ends/sfst/fst.h"
41 #include "back-ends/foma/fomalib.h"
53 #include "../HfstExceptionDefs.h"
54 #include "optimized-lookup/transducer.h"
59 #include "../HfstDataTypes.h"
67 namespace implementations {
70 typedef fst::StdArc::StateId StateId;
71 typedef fst::ArcIterator<fst::StdVectorFst> StdArcIterator;
74 typedef fst::ArcTpl<fst::LogWeight> LogArc;
75 typedef fst::VectorFst<LogArc> LogFst;
80 class ConversionFunctions {
84 typedef std::map<std::string, unsigned int> String2NumberMap;
85 typedef std::vector<unsigned int> NumberVector;
88 static StringVector number_to_string_vector;
91 static String2NumberMap string_to_number_map;
95 static std::string get_string(
unsigned int number);
99 static unsigned int get_number(
const std::string &str);
104 static NumberVector get_harmonization_vector
105 (
const StringVector &coding_vector);
111 static void sfst_to_hfst_basic_transducer
114 std::vector<unsigned int> &harmonization_vector);
117 (SFST::Transducer * t);
119 static SFST::Transducer * hfst_basic_transducer_to_sfst
146 static struct fsm * hfst_basic_transducer_to_foma
165 (fst::StdVectorFst * t,
bool has_hfst_header=
true);
167 static StateId hfst_state_to_state_id
168 (
HfstState s, std::map<HfstState, StateId> &state_map,
169 fst::StdVectorFst * t);
171 static fst::StdVectorFst * hfst_basic_transducer_to_tropical_ofst
191 (LogFst * t,
bool had_hfst_header=
true);
193 static StateId hfst_state_to_state_id
194 (
HfstState s, std::map<HfstState, StateId> &state_map,
197 static LogFst * hfst_basic_transducer_to_log_ofst
216 #endif // HAVE_OPENFST
225 std::string options=
"", HfstTransducer * harmonizer = NULL);
228 static HfstTransducer * hfst_ol_to_hfst_transducer
244 friend class StringVectorInitializer;
245 friend class String2NumberMapInitializer;
251 class StringVectorInitializer {
253 StringVectorInitializer
254 (StringVector &vector) {
255 vector.push_back(std::string(
"@_EPSILON_SYMBOL_@"));
256 vector.push_back(std::string(
"@_UNKNOWN_SYMBOL_@"));
257 vector.push_back(std::string(
"@_IDENTITY_SYMBOL_@"));
261 class String2NumberMapInitializer {
263 String2NumberMapInitializer
264 (ConversionFunctions::String2NumberMap &map) {
265 map[
"@_EPSILON_SYMBOL_@"] = 0;
266 map[
"@_UNKNOWN_SYMBOL_@"] = 1;
267 map[
"@_IDENTITY_SYMBOL_@"] = 2;
272 #endif // _CONVERT_TRANSDUCER_H_
A compiled transducer format, suitable for fast lookup operations.
Definition: 3831_transducer.h:804
unsigned int HfstState
The number of a state in an HfstTransitionGraph.
Definition: HfstDataTypes.h:120
A synchronous finite-state transducer.
Definition: HfstTransducer.h:227
HfstTransitionGraph< HfstTropicalTransducerTransitionData > HfstBasicTransducer
An HfstTransitionGraph with transitions of type HfstTropicalTransducerTransitionData and weight type ...
Definition: HfstDataTypes.h:114