FST  openfst-1.7.2
OpenFst Library
farscript.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 // Definitions of 'scriptable' versions of FAR operations, that is,
5 // those that can be called with FstClass-type arguments.
6 
10 
11 namespace fst {
12 namespace script {
13 
14 void FarCompileStrings(const std::vector<string> &in_fnames,
15  const string &out_fname, const string &arc_type,
16  const string &fst_type, const FarType &far_type,
17  int32 generate_keys, FarEntryType fet, FarTokenType tt,
18  const string &symbols_fname,
19  const string &unknown_symbol, bool keep_symbols,
20  bool initial_symbols, bool allow_negative_labels,
21  const string &key_prefix, const string &key_suffix) {
22  FarCompileStringsArgs args(in_fnames, out_fname, fst_type, far_type,
23  generate_keys, fet, tt, symbols_fname,
24  unknown_symbol, keep_symbols, initial_symbols,
25  allow_negative_labels, key_prefix, key_suffix);
26  Apply<Operation<FarCompileStringsArgs>>("FarCompileStrings", arc_type, &args);
27 }
28 
29 void FarCreate(const std::vector<string> &in_fnames, const string &out_fname,
30  const string &arc_type, const int32 generate_keys,
31  const FarType &far_type, const string &key_prefix,
32  const string &key_suffix) {
33  FarCreateArgs args(in_fnames, out_fname, generate_keys, far_type, key_prefix,
34  key_suffix);
35  Apply<Operation<FarCreateArgs>>("FarCreate", arc_type, &args);
36 }
37 
38 bool FarEqual(const string &filename1, const string &filename2,
39  const string &arc_type, float delta, const string &begin_key,
40  const string &end_key) {
41  FarEqualInnerArgs args(filename1, filename2, delta, begin_key, end_key);
42  FarEqualArgs args_with_retval(args);
43  Apply<Operation<FarEqualArgs>>("FarEqual", arc_type, &args_with_retval);
44  return args_with_retval.retval;
45 }
46 
47 void FarExtract(const std::vector<string> &ifilenames, const string &arc_type,
48  int32 generate_filenames, const string &keys,
49  const string &key_separator, const string &range_delimiter,
50  const string &filename_prefix, const string &filename_suffix) {
51  FarExtractArgs args(ifilenames, generate_filenames, keys, key_separator,
52  range_delimiter, filename_prefix, filename_suffix);
53  Apply<Operation<FarExtractArgs>>("FarExtract", arc_type, &args);
54 }
55 
56 void FarInfo(const std::vector<string> &filenames, const string &arc_type,
57  const string &begin_key, const string &end_key,
58  const bool list_fsts) {
59  FarInfoArgs args(filenames, begin_key, end_key, list_fsts);
60  Apply<Operation<FarInfoArgs>>("FarInfo", arc_type, &args);
61 }
62 
63 void GetFarInfo(const std::vector<string> &filenames, const string &arc_type,
64  const string &begin_key, const string &end_key,
65  const bool list_fsts, FarInfoData *data) {
66  GetFarInfoArgs args(filenames, begin_key, end_key, list_fsts, data);
67  Apply<Operation<GetFarInfoArgs>>("GetFarInfo", arc_type, &args);
68 }
69 
70 bool FarIsomorphic(const string &filename1, const string &filename2,
71  const string &arc_type, float delta, const string &begin_key,
72  const string &end_key) {
73  FarIsomorphicInnerArgs args(filename1, filename2, delta, begin_key, end_key);
74  FarIsomorphicArgs args_with_retval(args);
75  Apply<Operation<FarIsomorphicArgs>>("FarIsomorphic", arc_type,
76  &args_with_retval);
77  return args_with_retval.retval;
78 }
79 
80 void FarPrintStrings(const std::vector<string> &ifilenames,
81  const string &arc_type, const FarEntryType entry_type,
82  const FarTokenType token_type, const string &begin_key,
83  const string &end_key, const bool print_key,
84  const bool print_weight, const string &symbols_fname,
85  const bool initial_symbols, const int32 generate_filenames,
86  const string &filename_prefix,
87  const string &filename_suffix) {
88  FarPrintStringsArgs args(ifilenames, entry_type, token_type, begin_key,
89  end_key, print_key, print_weight, symbols_fname,
90  initial_symbols, generate_filenames, filename_prefix,
91  filename_suffix);
92  Apply<Operation<FarPrintStringsArgs>>("FarPrintStrings", arc_type, &args);
93 }
94 
95 // Instantiate all templates for common arc types.
96 
100 
101 } // namespace script
102 } // namespace fst
void FarInfo(const std::vector< string > &filenames, const string &arc_type, const string &begin_key, const string &end_key, const bool list_fsts)
Definition: farscript.cc:56
void FarPrintStrings(const std::vector< string > &ifilenames, const string &arc_type, const FarEntryType entry_type, const FarTokenType token_type, const string &begin_key, const string &end_key, const bool print_key, const bool print_weight, const string &symbols_fname, const bool initial_symbols, const int32 generate_filenames, const string &filename_prefix, const string &filename_suffix)
Definition: farscript.cc:80
std::tuple< const string &, const string &, float, const string &, const string & > FarIsomorphicInnerArgs
Definition: farscript.h:185
void FarCreate(const std::vector< string > &in_fnames, const string &out_fname, const string &arc_type, const int32 generate_keys, const FarType &far_type, const string &key_prefix, const string &key_suffix)
Definition: farscript.cc:29
std::tuple< const std::vector< string > &, const string &, const string &, const bool, FarInfoData * > GetFarInfoArgs
Definition: farscript.h:171
FarTokenType
Definition: far.h:23
std::tuple< const string &, const string &, float, const string &, const string & > FarEqualInnerArgs
Definition: farscript.h:124
FarType
Definition: far.h:71
void FarExtract(const std::vector< string > &ifilenames, const string &arc_type, int32 generate_filenames, const string &keys, const string &key_separator, const string &range_delimiter, const string &filename_prefix, const string &filename_suffix)
Definition: farscript.cc:47
bool FarEqual(const string &filename1, const string &filename2, const string &arc_type, float delta, const string &begin_key, const string &end_key)
Definition: farscript.cc:38
std::tuple< const std::vector< string > &, const string &, const string &, const bool > FarInfoArgs
Definition: farscript.h:158
bool FarIsomorphic(const string &filename1, const string &filename2, const string &arc_type, float delta, const string &begin_key, const string &end_key)
Definition: farscript.cc:70
std::tuple< const std::vector< string > &, int32, const string &, const string &, const string &, const string &, const string & > FarExtractArgs
Definition: farscript.h:142
REGISTER_FST_FAR_OPERATIONS(StdArc)
void GetFarInfo(const std::vector< string > &filenames, const string &arc_type, const string &begin_key, const string &end_key, const bool list_fsts, FarInfoData *data)
Definition: farscript.cc:63
int32_t int32
Definition: types.h:26
void FarCompileStrings(const std::vector< string > &in_fnames, const string &out_fname, const string &arc_type, const string &fst_type, const FarType &far_type, int32 generate_keys, FarEntryType fet, FarTokenType tt, const string &symbols_fname, const string &unknown_symbol, bool keep_symbols, bool initial_symbols, bool allow_negative_labels, const string &key_prefix, const string &key_suffix)
Definition: farscript.cc:14
FarEntryType
Definition: far.h:21