33 my_string =
"default dummy string";
38 "An int32 variable in DummyOptions.");
40 "A Boolean varaible in DummyOptions.");
42 "A string varaible in DummyOptions.");
48 std::string str=
"default_for_str";
51 const char *argv[7] = {
"program_name",
"--unum=5",
"--num=3",
"--i=boo",
54 po.
Register(
"i", &str,
"My variable");
55 po.
Register(
"num", &num,
"My int32 variable");
56 po.
Register(
"unum", &unum,
"My uint32 variable");
68 const char *argv2[4] = {
"program_name",
"--i=foo",
69 "--to-be-NORMALIZED=test",
"c" };
70 std::string str2 =
"default_for_str2";
71 po2.
Register(
"To_Be_Normalized", &str2,
72 "My variable (name has to be normalized)");
73 po2.
Register(
"i", &str,
"My variable");
74 po2.
Read(argc2, argv2);
84 po3.
Register(
"str", &str,
"My string variable");
85 po3.
Register(
"num", &num,
"My int32 variable");
87 ro3.
Register(
"unum", &unum,
"My uint32 variable");
88 ro3.
Register(
"str", &str2,
"My other string variable");
90 so3.
Register(
"unum", &unum2,
"Another uint32 variable");
93 const char *argv3[10] = {
94 "program_name",
"--prefix.unum=5",
"--num=3",
95 "--prefix.str=foo",
"--str=bar",
"--prefix.my-bool=false",
96 "--prefix.my-str=baz",
"--prefix.prefix2.unum=42",
"a",
"b" };
101 po3.
Read(argc3, argv3);
117 const char *argv4[2] = {
"program_name",
"--option="};
120 po4.
Register(
"option", &val,
"My boolean");
121 po4.
Read(argc4, argv4);
123 }
catch(std::exception e) {
124 KALDI_LOG <<
"Failed to read option (this is expected).";
129 const char *argv4[2] = {
"program_name",
"--option"};
132 po4.
Register(
"option", &val,
"My boolean");
133 po4.
Read(argc4, argv4);
141 const char *argv4[2] = {
"program_name",
"--option"};
144 po4.
Register(
"option", &val,
"My string");
145 po4.
Read(argc4, argv4);
147 }
catch(std::exception e) {
148 KALDI_LOG <<
"Failed to read option (this is expected).";
153 const char *argv4[2] = {
"program_name",
"--option="};
155 std::string val =
"foo";
156 po4.
Register(
"option", &val,
"My boolean");
157 po4.
Read(argc4, argv4);
163 const char *argv4[2] = {
"program_name",
"--option=8"};
166 po4.
Register(
"option", &val,
"My int");
167 po4.
Read(argc4, argv4);
173 const char *argv4[2] = {
"program_name",
"--option=8.5"};
176 po4.
Register(
"option", &val,
"My float");
177 po4.
Read(argc4, argv4);
182 const char *argv4[2] = {
"program_name",
"--option=bar"};
184 std::string val =
"foo";
185 po4.
Register(
"option", &val,
"My string");
186 po4.
Read(argc4, argv4);
192 const char *argv4[2] = {
"program_name",
"--option=foo"};
195 po4.
Register(
"option", &val,
"My float");
196 po4.
Read(argc4, argv4);
198 }
catch(std::exception e) {
199 KALDI_LOG <<
"Failed to read option (this is expected).";
205 const char *argv4[2] = {
"program_name",
"--option=foo"};
208 po4.
Register(
"option", &val,
"My int");
209 po4.
Read(argc4, argv4);
211 }
catch(std::exception e) {
212 KALDI_LOG <<
"Failed to read option (this is expected).";
217 const char *argv4[2] = {
"program_name",
"--option=12xyz"};
220 po4.
Register(
"option", &val,
"My int");
221 po4.
Read(argc4, argv4);
223 }
catch(std::exception e) {
224 KALDI_LOG <<
"Failed to read option (this is expected).";
229 const char *argv4[2] = {
"program_name",
"--option=-13"};
232 po4.
Register(
"option", &val,
"My int");
233 po4.
Read(argc4, argv4);
235 }
catch(std::exception e) {
236 KALDI_LOG <<
"Failed to read option (this is expected)xxx.";
241 const char *argv4[2] = {
"program_name",
"--option=foo"};
244 po4.
Register(
"option", &val,
"My bool");
245 po4.
Read(argc4, argv4);
247 }
catch(std::exception e) {
248 KALDI_LOG <<
"Failed to read option (this is expected).";
255 const char *argv4[2] = {
"program_name",
"--=8"};
258 po4.
Register(
"num", &num,
"My int32 variable");
259 po4.
Read(argc4, argv4);
261 }
catch(std::exception e) {
262 KALDI_LOG <<
"Failed to read option (this is expected).";
268 const char *argv4[5] = {
"program_name",
"--unum=6",
"--",
"a",
"b" };
270 po4.
Register(
"unum", &unum,
"My uint32 variable");
271 po4.
Read(argc4, argv4);
280 const char *argv5[3] = {
"program_name",
"--unum=7",
"--" };
282 po5.
Register(
"unum", &unum,
"My uint32 variable");
283 po5.
Read(argc5, argv5);
290 const char *argv6[5] = {
"program_name",
"--unum=8",
"--",
"--foo=8" };
292 po6.
Register(
"unum", &unum,
"My uint32 variable");
293 po6.
Read(argc6, argv6);
302 using namespace kaldi;
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void UnitTestParseOptions()
void Register(const std::string &name, bool *ptr, const std::string &doc)
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
#define KALDI_ASSERT(cond)
void Register(ParseOptions *po)