FST  openfst-1.7.2
OpenFst Library
far-class.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 
5 
8 
9 namespace fst {
10 namespace script {
11 
12 
13 // FarReaderClass.
14 
15 FarReaderClass *FarReaderClass::Open(const string &filename) {
16  const std::vector<string> filenames{filename};
17  return FarReaderClass::Open(filenames);
18 }
19 
20 FarReaderClass *FarReaderClass::Open(const std::vector<string> &filenames) {
21  if (filenames.empty()) {
22  LOG(ERROR) << "FarReaderClass::Open: No files specified";
23  return nullptr;
24  }
25  const auto arc_type = LoadArcTypeFromFar(filenames.front());
26  if (arc_type.empty()) return nullptr;
27  OpenFarReaderClassArgs args(filenames);
28  args.retval = nullptr;
29  Apply<Operation<OpenFarReaderClassArgs>>("OpenFarReaderClass", arc_type,
30  &args);
31  return args.retval;
32 }
33 
37 
38 // FarWriterClass.
39 
40 FarWriterClass *FarWriterClass::Create(const string &filename,
41  const string &arc_type, FarType type) {
42  CreateFarWriterClassInnerArgs iargs(filename, type);
43  CreateFarWriterClassArgs args(iargs);
44  args.retval = nullptr;
45  Apply<Operation<CreateFarWriterClassArgs>>("CreateFarWriterClass", arc_type,
46  &args);
47  return args.retval;
48 }
49 
54 
55 } // namespace script
56 } // namespace fst
static FarReaderClass * Open(const string &filename)
Definition: far-class.cc:15
#define LOG(type)
Definition: log.h:48
REGISTER_FST_OPERATION(Compress, StdArc, CompressArgs)
FarType
Definition: far.h:71
static FarWriterClass * Create(const string &filename, const string &arc_type, FarType type=FAR_DEFAULT)
Definition: far-class.cc:40
void CreateFarWriterClass(CreateFarWriterClassArgs *args)
Definition: far-class.h:250
std::pair< const string &, FarType > CreateFarWriterClassInnerArgs
Definition: far-class.h:198
friend void OpenFarReaderClass(OpenFarReaderClassArgs *args)
Definition: far-class.h:144
string LoadArcTypeFromFar(const string &far_fname)
Definition: script-impl.cc:17