Merge "Use LanguageModelDictContent in iterateNgramEntries()."
commit
7c08ede12b
|
@ -158,11 +158,21 @@ void Ver4PatriciaTriePolicy::iterateNgramEntries(const int *const prevWordsPtNod
|
||||||
if (!prevWordsPtNodePos) {
|
if (!prevWordsPtNodePos) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
|
// TODO: Support n-gram.
|
||||||
BinaryDictionaryBigramsIterator bigramsIt(&mBigramPolicy, bigramsPosition);
|
const PtNodeParams ptNodeParams =
|
||||||
while (bigramsIt.hasNext()) {
|
mNodeReader.fetchPtNodeParamsInBufferFromPtNodePos(prevWordsPtNodePos[0]);
|
||||||
bigramsIt.next();
|
const int prevWordId = ptNodeParams.getTerminalId();
|
||||||
listener->onVisitEntry(bigramsIt.getProbability(), bigramsIt.getBigramPos());
|
const WordIdArrayView prevWordIds = WordIdArrayView::fromObject(&prevWordId);
|
||||||
|
const auto languageModelDictContent = mBuffers->getLanguageModelDictContent();
|
||||||
|
for (const auto entry : languageModelDictContent->getProbabilityEntries(prevWordIds)) {
|
||||||
|
const ProbabilityEntry &probabilityEntry = entry.getProbabilityEntry();
|
||||||
|
const int probability = probabilityEntry.hasHistoricalInfo() ?
|
||||||
|
ForgettingCurveUtils::decodeProbability(
|
||||||
|
probabilityEntry.getHistoricalInfo(), mHeaderPolicy) :
|
||||||
|
probabilityEntry.getProbability();
|
||||||
|
const int ptNodePos = mBuffers->getTerminalPositionLookupTable()->getTerminalPtNodePosition(
|
||||||
|
entry.getWordId());
|
||||||
|
listener->onVisitEntry(probability, ptNodePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue