Blame view

tools/openfst-1.6.7/src/extensions/far/getters.cc 1.48 KB
8dcb6dfcb   Yannick Estève   first commit
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
  // See www.openfst.org for extensive documentation on this weighted
  // finite-state transducer library.
  //
  //
  // Definitions and functions for invoking and using Far main functions that
  // support multiple and extensible arc types.
  
  #include <fst/extensions/far/getters.h>
  
  #include <string>
  #include <vector>
  
  #include <fstream>
  
  namespace fst {
  
  namespace script {
  
  FarType GetFarType(const string &str) {
    if (str == "fst") {
      return FAR_FST;
    } else if (str == "stlist") {
      return FAR_STLIST;
    } else if (str == "sttable") {
      return FAR_STTABLE;
    } else {
      return FAR_DEFAULT;
    }
  }
  
  bool GetFarEntryType(const string &str, FarEntryType *entry_type) {
    if (str == "line") {
      *entry_type = FET_LINE;
    } else if (str == "file") {
      *entry_type = FET_FILE;
    } else {
      return false;
    }
    return true;
  }
  
  bool GetFarTokenType(const string &str, FarTokenType *token_type) {
    if (str == "symbol") {
      *token_type = FTT_SYMBOL;
    } else if (str == "byte") {
      *token_type = FTT_BYTE;
    } else if (str == "utf8") {
      *token_type = FTT_UTF8;
    } else {
      return false;
    }
    return true;
  }
  
  void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp) {
  }
  
  }  // namespace script
  
  string GetFarTypeString(FarType type) {
    switch (type) {
      case FAR_FST:
        return "fst";
      case FAR_STLIST:
        return "stlist";
      case FAR_STTABLE:
        return "sttable";
      case FAR_DEFAULT:
        return "default";
      default:
        return "<unknown>";
    }
  }
  
  }  // namespace fst