Phonetisaurus  1.0
FST-based Grapheme-to-Phoneme conversion
phonetisaurus-arpa2wfst.cc
Go to the documentation of this file.
1 /*
2  phonetisaurus-arpa2wfst.cc
3 
4  Copyright (c) [2012-], Josef Robert Novak
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without
8  modification, are permitted #provided that the following conditions
9  are met:
10 
11  * Redistributions of source code must retain the above copyright
12  notice, this list of conditions and the following disclaimer.
13  * Redistributions in binary form must reproduce the above
14  copyright notice, this list of #conditions and the following
15  disclaimer in the documentation and/or other materials provided
16  with the distribution.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32 #include <include/ARPA2WFST.h>
33 #include <include/util.h>
34 
35 using namespace fst;
36 
37 DEFINE_string (lm, "", "Input ARPA format LM.");
38 DEFINE_string (eps, "<eps>", "Epsilon symbol.");
39 DEFINE_string (sb, "<s>", "Sentence begin token.");
40 DEFINE_string (se, "</s>", "Sentence end token.");
41 DEFINE_string (split, "}", "Character separating grapheme/phoneme info.");
42 DEFINE_string (skip, "_", "Character indicating insertions/deletions.");
43 DEFINE_string (tie, "|", "Character separating multi-token subsequences.");
44 DEFINE_string (ofile, "", "Output file for writing. (STDOUT)");
45 
46 int main (int argc, char* argv []) {
47  string usage = "arpa2wfsa - Transform an ARPA LM into an "
48  "equivalent WFSA.\n\n Usage: ";
49  set_new_handler (FailedNewHandler);
50  PhonetisaurusSetFlags (usage.c_str(), &argc, &argv, false);
51 
52  if (FLAGS_lm.compare ("") == 0) {
53  cerr << "You must supply an ARPA format lm "
54  "to --lm for conversion!" << endl;
55  return 0;
56  }
57 
58  cerr << "Initializing..." << endl;
59  ARPA2WFST* converter = new ARPA2WFST (FLAGS_lm, FLAGS_eps, FLAGS_sb,
60  FLAGS_se, FLAGS_split, FLAGS_skip,
61  FLAGS_tie);
62  cerr << "Converting..." << endl;
63  converter->arpa_to_wfst ();
64 
65  converter->arpafst.Write (FLAGS_ofile);
66  delete converter;
67 
68  return 0;
69 }
void PhonetisaurusSetFlags(const char *usage, int *argc, char ***argv, bool remove_flags)
Definition: util.cc:158
void arpa_to_wfst()
Definition: ARPA2WFST.h:106
int main(int argc, char *argv[])
DEFINE_string(lm,"","Input ARPA format LM.")
VectorFst< StdArc > arpafst
Definition: ARPA2WFST.h:74