FST
openfst-1.7.1
OpenFst Library
Main Page
Namespaces
Classes
Files
File List
File Members
src
fst
openfst-1.7.1
src
bin
fstequal-main.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
// Two FSTS are equal iff their exit status is zero.
5
6
#include <cstring>
7
8
#include <memory>
9
#include <string>
10
11
#include <
fst/flags.h
>
12
#include <
fst/log.h
>
13
#include <
fst/script/equal.h
>
14
15
DECLARE_double
(delta);
16
17
int
fstequal_main
(
int
argc,
char
**argv) {
18
namespace
s =
fst::script
;
19
using
fst::script::FstClass
;
20
21
string
usage =
"Two FSTs are equal iff the exit status is zero.\n\n Usage: "
;
22
usage += argv[0];
23
usage +=
" in1.fst in2.fst\n"
;
24
25
std::set_new_handler(
FailedNewHandler
);
26
SET_FLAGS
(usage.c_str(), &argc, &argv,
true
);
27
if
(argc != 3) {
28
ShowUsage
();
29
return
1;
30
}
31
32
const
string
in1_name = strcmp(argv[1],
"-"
) == 0 ?
""
: argv[1];
33
const
string
in2_name = strcmp(argv[2],
"-"
) == 0 ?
""
: argv[2];
34
35
if
(in1_name.empty() && in2_name.empty()) {
36
LOG
(ERROR) << argv[0] <<
": Can't take both inputs from standard input"
;
37
return
1;
38
}
39
40
std::unique_ptr<FstClass> ifst1(FstClass::Read(in1_name));
41
if
(!ifst1)
return
1;
42
43
std::unique_ptr<FstClass> ifst2(FstClass::Read(in2_name));
44
if
(!ifst2)
return
1;
45
46
bool
result =
s::Equal
(*ifst1, *ifst2, FLAGS_delta);
47
if
(!result)
VLOG
(1) <<
"FSTs are not equal."
;
48
49
return
result ? 0 : 2;
50
}
ShowUsage
void ShowUsage(bool long_usage=true)
Definition:
flags.cc:124
equal.h
LOG
#define LOG(type)
Definition:
log.h:48
fstequal_main
int fstequal_main(int argc, char **argv)
Definition:
fstequal-main.cc:17
FailedNewHandler
void FailedNewHandler()
Definition:
compat.cc:25
SET_FLAGS
#define SET_FLAGS(usage, argc, argv, rmflags)
Definition:
flags.h:214
fst::script
Definition:
compress-script.cc:16
VLOG
#define VLOG(level)
Definition:
log.h:49
DECLARE_double
DECLARE_double(delta)
fst::Equal
bool Equal(const Fst< Arc > &fst1, const Fst< Arc > &fst2, WeightEqual weight_equal, uint32 etype=kEqualFsts)
Definition:
equal.h:43
flags.h
fst::script::FstClass
Definition:
fst-class.h:273
log.h
Generated by
1.8.11