FST  openfst-1.7.1
OpenFst Library
getters.cc
Go to the documentation of this file.
1 #include <fst/script/getters.h>
2 
3 namespace fst {
4 namespace script {
5 
6 bool GetArcSortType(const string &str, ArcSortType *sort_type) {
7  if (str == "ilabel") {
8  *sort_type = ILABEL_SORT;
9  } else if (str == "olabel") {
10  *sort_type = OLABEL_SORT;
11  } else {
12  return false;
13  }
14  return true;
15 }
16 
17 bool GetComposeFilter(const string &str, ComposeFilter *compose_filter) {
18  if (str == "alt_sequence") {
19  *compose_filter = ALT_SEQUENCE_FILTER;
20  } else if (str == "auto") {
21  *compose_filter = AUTO_FILTER;
22  } else if (str == "match") {
23  *compose_filter = MATCH_FILTER;
24  } else if (str == "null") {
25  *compose_filter = NULL_FILTER;
26  } else if (str == "sequence") {
27  *compose_filter = SEQUENCE_FILTER;
28  } else if (str == "trivial") {
29  *compose_filter = TRIVIAL_FILTER;
30  } else {
31  return false;
32  }
33  return true;
34 }
35 
36 bool GetDeterminizeType(const string &str, DeterminizeType *det_type) {
37  if (str == "functional") {
38  *det_type = DETERMINIZE_FUNCTIONAL;
39  } else if (str == "nonfunctional") {
40  *det_type = DETERMINIZE_NONFUNCTIONAL;
41  } else if (str == "disambiguate") {
42  *det_type = DETERMINIZE_DISAMBIGUATE;
43  } else {
44  return false;
45  }
46  return true;
47 }
48 
49 bool GetMapType(const string &str, MapType *map_type) {
50  if (str == "arc_sum") {
51  *map_type = ARC_SUM_MAPPER;
52  } else if (str == "arc_unique") {
53  *map_type = ARC_UNIQUE_MAPPER;
54  } else if (str == "identity") {
55  *map_type = IDENTITY_MAPPER;
56  } else if (str == "input_epsilon") {
57  *map_type = INPUT_EPSILON_MAPPER;
58  } else if (str == "invert") {
59  *map_type = INVERT_MAPPER;
60  } else if (str == "output_epsilon") {
61  *map_type = OUTPUT_EPSILON_MAPPER;
62  } else if (str == "plus") {
63  *map_type = PLUS_MAPPER;
64  } else if (str == "power") {
65  *map_type = POWER_MAPPER;
66  } else if (str == "quantize") {
67  *map_type = QUANTIZE_MAPPER;
68  } else if (str == "rmweight") {
69  *map_type = RMWEIGHT_MAPPER;
70  } else if (str == "superfinal") {
71  *map_type = SUPERFINAL_MAPPER;
72  } else if (str == "times") {
73  *map_type = TIMES_MAPPER;
74  } else if (str == "to_log") {
75  *map_type = TO_LOG_MAPPER;
76  } else if (str == "to_log64") {
77  *map_type = TO_LOG64_MAPPER;
78  } else if (str == "to_std" || str == "to_standard") {
79  *map_type = TO_STD_MAPPER;
80  } else {
81  return false;
82  }
83  return true;
84 }
85 
86 bool GetRandArcSelection(const string &str, RandArcSelection *ras) {
87  if (str == "uniform") {
88  *ras = UNIFORM_ARC_SELECTOR;
89  } else if (str == "log_prob") {
90  *ras = LOG_PROB_ARC_SELECTOR;
91  } else if (str == "fast_log_prob") {
93  } else {
94  return false;
95  }
96  return true;
97 }
98 
99 bool GetQueueType(const string &str, QueueType *queue_type) {
100  if (str == "auto") {
101  *queue_type = AUTO_QUEUE;
102  } else if (str == "fifo") {
103  *queue_type = FIFO_QUEUE;
104  } else if (str == "lifo") {
105  *queue_type = LIFO_QUEUE;
106  } else if (str == "shortest") {
107  *queue_type = SHORTEST_FIRST_QUEUE;
108  } else if (str == "state") {
109  *queue_type = STATE_ORDER_QUEUE;
110  } else if (str == "top") {
111  *queue_type = TOP_ORDER_QUEUE;
112  } else {
113  return false;
114  }
115  return true;
116 }
117 
118 bool GetReplaceLabelType(const string &str, bool epsilon_on_replace,
119  ReplaceLabelType *rlt) {
120  if (epsilon_on_replace || str == "neither") {
121  *rlt = REPLACE_LABEL_NEITHER;
122  } else if (str == "input") {
123  *rlt = REPLACE_LABEL_INPUT;
124  } else if (str == "output") {
125  *rlt = REPLACE_LABEL_OUTPUT;
126  } else if (str == "both") {
127  *rlt = REPLACE_LABEL_BOTH;
128  } else {
129  return false;
130  }
131  return true;
132 }
133 
134 } // namespace script
135 } // namespace fst
MapType
Definition: map.h:37
QueueType
Definition: queue.h:55
ReplaceLabelType
Definition: replace-util.h:27
bool GetRandArcSelection(const string &str, RandArcSelection *ras)
Definition: getters.cc:86
bool GetReplaceLabelType(const string &str, bool epsilon_on_replace, ReplaceLabelType *rlt)
Definition: getters.cc:118
bool GetArcSortType(const string &str, ArcSortType *sort_type)
Definition: getters.cc:6
bool GetMapType(const string &str, MapType *map_type)
Definition: getters.cc:49
bool GetQueueType(const string &str, QueueType *queue_type)
Definition: getters.cc:99
bool GetDeterminizeType(const string &str, DeterminizeType *det_type)
Definition: getters.cc:36
ComposeFilter
Definition: compose.h:929
bool GetComposeFilter(const string &str, ComposeFilter *compose_filter)
Definition: getters.cc:17
DeterminizeType
Definition: determinize.h:358