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