10 #ifndef _CONVERT_TRANSDUCER_H_
11 #define _CONVERT_TRANSDUCER_H_
15 #endif // HAVE_CONFIG_H
24 #include "back-ends/openfstwin/src/include/fst/fstlib.h"
26 #include "back-ends/openfst/src/include/fst/fstlib.h"
28 #endif // HAVE_OPENFST
31 #include "back-ends/sfst/fst.h"
37 #include "back-ends/foma/fomalib.h"
42 #include "xfsm/xfsm_api.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
170 (fst::StdVectorFst * t,
bool has_hfst_header=
true);
172 static StateId hfst_state_to_state_id
173 (
HfstState s, std::map<HfstState, StateId> &state_map,
174 fst::StdVectorFst * t);
176 static fst::StdVectorFst * hfst_basic_transducer_to_tropical_ofst
196 (LogFst * t,
bool had_hfst_header=
true);
198 static StateId hfst_state_to_state_id
199 (
HfstState s, std::map<HfstState, StateId> &state_map,
202 static LogFst * hfst_basic_transducer_to_log_ofst
221 #endif // HAVE_OPENFST
230 std::string options=
"", HfstTransducer * harmonizer = NULL);
233 static HfstTransducer * hfst_ol_to_hfst_transducer
249 friend class StringVectorInitializer;
250 friend class String2NumberMapInitializer;
256 class StringVectorInitializer {
258 StringVectorInitializer
259 (StringVector &vector) {
260 vector.push_back(std::string(
"@_EPSILON_SYMBOL_@"));
261 vector.push_back(std::string(
"@_UNKNOWN_SYMBOL_@"));
262 vector.push_back(std::string(
"@_IDENTITY_SYMBOL_@"));
266 class String2NumberMapInitializer {
268 String2NumberMapInitializer
269 (ConversionFunctions::String2NumberMap &map) {
270 map[
"@_EPSILON_SYMBOL_@"] = 0;
271 map[
"@_UNKNOWN_SYMBOL_@"] = 1;
272 map[
"@_IDENTITY_SYMBOL_@"] = 2;
277 #endif // _CONVERT_TRANSDUCER_H_
A compiled transducer format, suitable for fast lookup operations.
Definition: transducer.h:833
unsigned int HfstState
The number of a state in an HfstTransitionGraph.
Definition: HfstDataTypes.h:119
A synchronous finite-state transducer.
Definition: HfstTransducer.h:253
HfstTransitionGraph< HfstTropicalTransducerTransitionData > HfstBasicTransducer
An HfstTransitionGraph with transitions of type HfstTropicalTransducerTransitionData and weight type ...
Definition: HfstDataTypes.h:113