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