?? dynamicphrasetable.h
字號:
#pragma once
#include <string>
#include <hash_map>
#include <vector>
#include <algorithm>
using std::string;
using stdext::hash_map;
using std::vector;
static const double DYNAMIC_FREQUENCY_INCREASEMENT = 0.5 ;
class ID
{
public:
int id;
double frequency;
ID(int id,double frequency)
{
this->id = id;
this->frequency = frequency;
}
int getid()
{
return id;
}
double getfrequency()
{
return frequency;
}
bool operator < (ID other)
{
return frequency > other.frequency ;
}
bool operator == (ID other)
{
return this->id == other.id;
}
};
class DynamicPhraseTable
{
public:
DynamicPhraseTable();
bool GetVectorByPhrase(const string& strPYPhrase, vector<ID> &vecPhrase);
bool InsertPhrase(const string& strPYPhrase,int nid,double frequency );
//Get the word by py, using longest-matching strategy, return the longest matching count
int GetPhraseByLongestMatchPy(const string& strPy, vector<ID> &vecPhraseID) ;
bool IncreaseFrequency(const string& strPy, int id);
bool Save(const string& strFileName) ;
bool Load(const string& strFilename) ;
protected:
private:
hash_map<string, vector<ID> > m_Phrase2VectorMap; //插入動態表
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -