am d70b8ff2: Fix: BoS bigram from user history dictionary is too strong.

* commit 'd70b8ff2917c027268e9bc1178b4e035164a5ca8':
  Fix: BoS bigram from user history dictionary is too strong.
main
Keisuke Kuroyanagi 2014-10-13 09:16:20 +00:00 committed by Android Git Automerger
commit 0a0dcafa53
2 changed files with 10 additions and 4 deletions

View File

@ -186,7 +186,9 @@ int Ver4PatriciaTriePolicy::getProbabilityOfWord(const WordIdArrayView prevWordI
if (bigramsIt.getBigramPos() == ptNodePos
&& bigramsIt.getProbability() != NOT_A_PROBABILITY) {
const int bigramConditionalProbability = getBigramConditionalProbability(
prevWordPtNodeParams.getProbability(), bigramsIt.getProbability());
prevWordPtNodeParams.getProbability(),
prevWordPtNodeParams.representsBeginningOfSentence(),
bigramsIt.getProbability());
return getProbability(ptNodeParams.getProbability(), bigramConditionalProbability);
}
}
@ -209,15 +211,19 @@ void Ver4PatriciaTriePolicy::iterateNgramEntries(const WordIdArrayView prevWordI
while (bigramsIt.hasNext()) {
bigramsIt.next();
const int bigramConditionalProbability = getBigramConditionalProbability(
prevWordPtNodeParams.getProbability(), bigramsIt.getProbability());
prevWordPtNodeParams.getProbability(),
prevWordPtNodeParams.representsBeginningOfSentence(), bigramsIt.getProbability());
listener->onVisitEntry(bigramConditionalProbability,
getWordIdFromTerminalPtNodePos(bigramsIt.getBigramPos()));
}
}
int Ver4PatriciaTriePolicy::getBigramConditionalProbability(const int prevWordUnigramProbability,
const int bigramProbability) const {
const bool isInBeginningOfSentenceContext, const int bigramProbability) const {
if (mHeaderPolicy->hasHistoricalInfoOfWords()) {
if (isInBeginningOfSentenceContext) {
return bigramProbability;
}
// Calculate conditional probability.
return std::min(MAX_PROBABILITY - prevWordUnigramProbability + bigramProbability,
MAX_PROBABILITY);

View File

@ -175,7 +175,7 @@ class Ver4PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy {
const WordAttributes getWordAttributes(const int probability,
const PtNodeParams &ptNodeParams) const;
int getBigramConditionalProbability(const int prevWordUnigramProbability,
const int bigramProbability) const;
const bool isInBeginningOfSentenceContext, const int bigramProbability) const;
};
} // namespace v402
} // namespace backward