FST  openfst-1.7.2
OpenFst Library
getters.cc
Go to the documentation of this file.
1 // See www.openfst.org for extensive documentation on this weighted
2 // finite-state transducer library.
3 //
4 //
5 // Definitions and functions for invoking and using Far main functions that
6 // support multiple and extensible arc types.
7 
9 
10 #include <string>
11 #include <vector>
12 
13 #include <fstream>
14 
15 namespace fst {
16 
17 namespace script {
18 
19 FarType GetFarType(const string &str) {
20  if (str == "fst") {
21  return FAR_FST;
22  } else if (str == "stlist") {
23  return FAR_STLIST;
24  } else if (str == "sttable") {
25  return FAR_STTABLE;
26  } else {
27  return FAR_DEFAULT;
28  }
29 }
30 
31 bool GetFarEntryType(const string &str, FarEntryType *entry_type) {
32  if (str == "line") {
33  *entry_type = FET_LINE;
34  } else if (str == "file") {
35  *entry_type = FET_FILE;
36  } else {
37  return false;
38  }
39  return true;
40 }
41 
42 bool GetFarTokenType(const string &str, FarTokenType *token_type) {
43  if (str == "symbol") {
44  *token_type = FTT_SYMBOL;
45  } else if (str == "byte") {
46  *token_type = FTT_BYTE;
47  } else if (str == "utf8") {
48  *token_type = FTT_UTF8;
49  } else {
50  return false;
51  }
52  return true;
53 }
54 
55 void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp) {
56 }
57 
58 } // namespace script
59 
60 string GetFarTypeString(FarType type) {
61  switch (type) {
62  case FAR_FST:
63  return "fst";
64  case FAR_STLIST:
65  return "stlist";
66  case FAR_STTABLE:
67  return "sttable";
68  case FAR_DEFAULT:
69  return "default";
70  default:
71  return "<unknown>";
72  }
73 }
74 
75 } // namespace fst
FarType GetFarType(const string &str)
Definition: getters.cc:19
void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp)
Definition: getters.cc:55
bool GetFarTokenType(const string &str, FarTokenType *token_type)
Definition: getters.cc:42
FarTokenType
Definition: far.h:23
FarType
Definition: far.h:71
string GetFarTypeString(FarType type)
Definition: getters.cc:60
bool GetFarEntryType(const string &str, FarEntryType *entry_type)
Definition: getters.cc:31
FarEntryType
Definition: far.h:21