Phonetisaurus  1.0
FST-based Grapheme-to-Phoneme conversion
util.h
Go to the documentation of this file.
1 #ifndef UTIL_H
2 #define UTIL_H
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 <fst/fstlib.h>
33 #include <utf8.h>
34 #include <unordered_map>
35 #ifdef __MACH__
36 #include <mach/clock.h>
37 #include <mach/mach.h>
38 #endif
39 using namespace fst;
40 
41 typedef struct LabelDatum { int max, tot, lhs, rhs; bool lhsE, rhsE; } LabelDatum;
42 typedef unordered_map<LogArc::Label,LabelDatum> LabelData;
43 
44 string vec2str (vector<string> vec, string sep);
45 
46 string itoas (int i);
47 
48 vector<string> tokenize_utf8_string (string* utf8_string, string* delimiter);
49 
50 vector<string> tokenize_entry (string* testword, string* sep,
51  SymbolTable* syms);
52 
53 vector<int> tokenize2ints (string* word, string* sep, const SymbolTable* syms);
54 
55 timespec get_time( );
56 
57 timespec diff (timespec start, timespec end);
58 
59 void PhonetisaurusSetFlags (const char* usage, int* argc, char*** argv,
60  bool remove_flags);
61 
62 void LoadWordList (const std::string& filename,
63  std::vector<std::string>* corpus);
64 
65 void Split (const std::string& s, char delim, std::vector<std::string>& elems);
66 
67 #endif //UTIL_H //
string itoas(int i)
Definition: util.cc:44
string vec2str(vector< string > vec, string sep)
Definition: util.cc:34
void PhonetisaurusSetFlags(const char *usage, int *argc, char ***argv, bool remove_flags)
Definition: util.cc:158
void Split(const std::string &s, char delim, std::vector< std::string > &elems)
Definition: util.cc:268
struct LabelDatum LabelDatum
int tot
Definition: util.h:41
vector< string > tokenize_entry(string *testword, string *sep, SymbolTable *syms)
Definition: util.cc:93
unordered_map< LogArc::Label, LabelDatum > LabelData
Definition: util.h:42
void LoadWordList(const std::string &filename, std::vector< std::string > *corpus)
Definition: util.cc:250
timespec diff(timespec start, timespec end)
Definition: util.cc:145
vector< string > tokenize_utf8_string(string *utf8_string, string *delimiter)
Definition: util.cc:50
vector< int > tokenize2ints(string *word, string *sep, const SymbolTable *syms)
Definition: util.cc:110
timespec get_time()
Definition: util.cc:138