00001 #pragma once
00002
00003 #include <string>
00004 #include <iostream>
00005
00006
00007 #ifdef WIN32
00008 #if defined _USRDLL
00009 #define DllExport _declspec(dllexport)
00010 #else
00011 #define DllExport _declspec(dllimport)
00012 #endif
00013 #else
00014 #define DllExport
00015 #endif
00016
00017 #ifdef WIN32
00018 #include <unordered_map>
00019 #else
00020 #include <tr1/unordered_map>
00021 #endif
00022
00023 struct LM_PROB
00024 {
00025 float m_fLogProb;
00026 float m_fLogBackOff;
00027 };
00028
00029 class DllExport CHLabLM
00030 {
00031
00032 std::tr1::unordered_map<std::string, LM_PROB> m_hashTrigram;
00033 std::tr1::unordered_map<std::string, LM_PROB> m_hashBigram;
00034 std::tr1::unordered_map<std::string, LM_PROB> m_hashUnigram;
00035
00036 public:
00037 CHLabLM(void);
00038 virtual ~CHLabLM(void);
00039
00040 int ReadLM(const char* szFile);
00041
00042 LM_PROB ComputeTrigramProb(std::string strTrigram);
00043 LM_PROB ComputeBigramProb (std::string strBigram);
00044 LM_PROB ComputeUnigramProb(std::string strBigram);
00045 float ComputeBigramProb();
00046 };