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