本文整理汇总了C++中HMM::convertString方法的典型用法代码示例。如果您正苦于以下问题:C++ HMM::convertString方法的具体用法?C++ HMM::convertString怎么用?C++ HMM::convertString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HMM
的用法示例。
在下文中一共展示了HMM::convertString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prior
int
Clusters::
reclusterNeyEssen()
{
cerr << "Calculating MLE for prior probabilities" << endl;
vector<double> prior(numberClasses,0.0l);
double xxx = 1.0l/(double)numberTypes;
for (int i = 0; i < numberTypes; i++){
int c = classVector[i];
prior[c] += xxx;
}
for (int i = 0; i < numberClasses;i++)
cerr << i << " " << prior[i] << endl;
if (numberStates > 0){
cerr << "Training all the HMMs" << endl;
for (int c = 0; c < numberClasses; c++){
// cerr << "Training HMM " << c << endl;
HMM* hmmPtr = hmms[c];
HMM* newHmmPtr = new HMM(numberStates, alphabetSize);
for (int i = 0; i < numberTypes; i++){
if (classVector[i] == c){
// then this word is in the right class
// so train it on word i
const string & word = *(corpus.wordArray[i]);
vector<int> v;
hmmPtr->convertString(word,v);
// FIXME
double weight = 1.0l;
if (USE_TRUE_WEIGHT){
weight = corpus.countArray[i];
}
hmmPtr->emSingle(*newHmmPtr, weight, v);
}
}
newHmmPtr->normalise();
hmms[c] = newHmmPtr;
delete hmmPtr;
}
}
int something = 0;
for (int i = 0; i < numberTypes; i++){
// cerr << "Word " << i;
int w = sortedWords[i];
//cerr << *(corpus.wordArray[w]) << endl;
if (counts[w] > FREQ_CUTOFF){
//cerr << "Doing " << w << endl;
if (bestCluster(w, prior)){
something++;
}
}
}
return something;
}