FST  openfst-1.8.3
OpenFst Library
getters.cc
Go to the documentation of this file.
1 // Copyright 2005-2024 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the 'License');
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an 'AS IS' BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // See www.openfst.org for extensive documentation on this weighted
16 // finite-state transducer library.
17 //
18 //
19 // Definitions and functions for invoking and using Far main functions that
20 // support multiple and extensible arc types.
21 
23 
24 #include <cstdint>
25 #include <string>
26 #include <vector>
27 
28 #include <fstream>
29 
30 namespace fst {
31 
32 namespace script {
33 
34 bool GetFarType(std::string_view str, FarType *far_type) {
35  if (str == "fst") {
36  *far_type = FarType::FST;
37  } else if (str == "stlist") {
38  *far_type = FarType::STLIST;
39  } else if (str == "sttable") {
40  *far_type = FarType::STTABLE;
41  } else if (str == "default") {
42  *far_type = FarType::DEFAULT;
43  } else {
44  return false;
45  }
46  return true;
47 }
48 
49 bool GetFarEntryType(std::string_view str, FarEntryType *entry_type) {
50  if (str == "line") {
51  *entry_type = FarEntryType::LINE;
52  } else if (str == "file") {
53  *entry_type = FarEntryType::FILE;
54  } else {
55  return false;
56  }
57  return true;
58 }
59 
60 void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp) {
61 }
62 
63 } // namespace script
64 
65 std::string GetFarTypeString(FarType far_type) {
66  switch (far_type) {
67  case FarType::FST:
68  return "fst";
69  case FarType::STLIST:
70  return "stlist";
71  case FarType::STTABLE:
72  return "sttable";
73  case FarType::DEFAULT:
74  return "default";
75  default:
76  return "<unknown>";
77  }
78 }
79 
80 } // namespace fst
std::string GetFarTypeString(FarType far_type)
Definition: getters.cc:65
void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp)
Definition: getters.cc:60
bool GetFarEntryType(std::string_view str, FarEntryType *entry_type)
Definition: getters.cc:49
FarType
Definition: far.h:51
bool GetFarType(std::string_view str, FarType *far_type)
Definition: getters.cc:34
FarEntryType
Definition: far.h:49