PageRenderTime 13ms CodeModel.GetById 8ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Phonetisaurus.hpp

https://code.google.com/p/phonetisaurus/
C++ Header | 70 lines | 33 code | 10 blank | 27 comment | 0 complexity | b94b97f65d0f017553149bfce0f77885 MD5 | raw file
 1#ifndef PHONETISAURUS_H
 2#define PHONETISAURUS_H
 3/*
 4    Phonetisaurus.hpp 
 5   
 6    Created by Josef Novak on 2011-04-07.
 7    Copyright 2011-2012 Josef Novak. All rights reserved.
 8
 9    This file is part of Phonetisaurus.
10
11    Phonetisaurus is free software: you can redistribute it 
12    and/or modify it under the terms of the GNU General Public 
13    License as published by the Free Software Foundation, either 
14    version 3 of the License, or (at your option) any later version.
15
16    Phonetisaurus is distributed in the hope that it will be useful, but 
17    WITHOUT ANY WARRANTY; without even the implied warranty of 
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
19    General Public License for more details.
20
21    You should have received a copy of the GNU General Public 
22    License along with Phonetisaurus. If not, see http://www.gnu.org/licenses/.
23 */
24#include <fst/fstlib.h>
25#include "FstPathFinder.hpp"
26#include "MBRDecoder.hpp"
27using namespace fst;
28
29class Phonetisaurus {
30    /*
31     Load a G2P/P2G model and generate pronunciation/spelling
32     hypotheses for input items.
33    */
34public:
35    //Basics
36    string        eps;
37    string        se;
38    string        sb;
39    string        skip;
40    string        tie;
41    int           order;
42    float         alpha;
43    float         theta;
44    bool          mbrdecode;
45    set<string>   skipSeqs;
46    map<vector<string>, int>   clusters;
47    //FST stuff
48    StdVectorFst  *g2pmodel;
49    StdVectorFst  epsMapper;
50    SymbolTable   *isyms;
51    SymbolTable   *osyms;
52        
53    Phonetisaurus( );
54        
55  Phonetisaurus( const char* g2pmodel_file, bool _mbrdecode, float alpha, float theta, int order );
56
57    StdVectorFst entryToFSA( vector<string> entry );
58
59    StdVectorFst makeEpsMapper( );
60    
61    vector<PathData> phoneticize( vector<string> entry, int nbest, int beam=500 );
62
63    bool printPaths( vector<PathData> paths, int nbest, string correct="", string word="" );
64    
65private:
66    void loadClusters( );
67
68};
69
70#endif // PHONETISAURUS_H //