Remove entry from language model dict content.
Bug: 14425059 Change-Id: Iea51c0ae908d499da19839de06222a1c4d19088e
parent
b4531d861e
commit
d3097c67ca
|
@ -45,12 +45,15 @@ ProbabilityEntry LanguageModelDictContent::getNgramProbabilityEntry(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LanguageModelDictContent::setNgramProbabilityEntry(const WordIdArrayView prevWordIds,
|
bool LanguageModelDictContent::setNgramProbabilityEntry(const WordIdArrayView prevWordIds,
|
||||||
const int terminalId, const ProbabilityEntry *const probabilityEntry) {
|
const int wordId, const ProbabilityEntry *const probabilityEntry) {
|
||||||
|
if (wordId == Ver4DictConstants::NOT_A_TERMINAL_ID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const int bitmapEntryIndex = createAndGetBitmapEntryIndex(prevWordIds);
|
const int bitmapEntryIndex = createAndGetBitmapEntryIndex(prevWordIds);
|
||||||
if (bitmapEntryIndex == TrieMap::INVALID_INDEX) {
|
if (bitmapEntryIndex == TrieMap::INVALID_INDEX) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mTrieMap.put(terminalId, probabilityEntry->encode(mHasHistoricalInfo), bitmapEntryIndex);
|
return mTrieMap.put(wordId, probabilityEntry->encode(mHasHistoricalInfo), bitmapEntryIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LanguageModelDictContent::removeNgramProbabilityEntry(const WordIdArrayView prevWordIds,
|
bool LanguageModelDictContent::removeNgramProbabilityEntry(const WordIdArrayView prevWordIds,
|
||||||
|
|
|
@ -255,6 +255,14 @@ bool Ver4PatriciaTrieNodeWriter::addNgramEntry(const WordIdArrayView prevWordIds
|
||||||
|
|
||||||
bool Ver4PatriciaTrieNodeWriter::removeNgramEntry(const WordIdArrayView prevWordIds,
|
bool Ver4PatriciaTrieNodeWriter::removeNgramEntry(const WordIdArrayView prevWordIds,
|
||||||
const int wordId) {
|
const int wordId) {
|
||||||
|
// TODO: Support n-gram.
|
||||||
|
LanguageModelDictContent *const languageModelDictContent =
|
||||||
|
mBuffers->getMutableLanguageModelDictContent();
|
||||||
|
if (!languageModelDictContent->removeNgramProbabilityEntry(prevWordIds.limit(1 /* maxSize */),
|
||||||
|
wordId)) {
|
||||||
|
// TODO: Uncomment.
|
||||||
|
// return false;
|
||||||
|
}
|
||||||
// TODO: Remove.
|
// TODO: Remove.
|
||||||
return mBigramPolicy->removeEntry(prevWordIds[0], wordId);
|
return mBigramPolicy->removeEntry(prevWordIds[0], wordId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,6 +263,11 @@ bool Ver4PatriciaTriePolicy::removeUnigramEntry(const int *const word, const int
|
||||||
AKLOGE("Cannot remove unigram. ptNodePos: %d", ptNodePos);
|
AKLOGE("Cannot remove unigram. ptNodePos: %d", ptNodePos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!mBuffers->getMutableLanguageModelDictContent()->removeProbabilityEntry(
|
||||||
|
ptNodeParams.getTerminalId())) {
|
||||||
|
// TODO: Uncomment.
|
||||||
|
// return false;
|
||||||
|
}
|
||||||
if (!ptNodeParams.representsNonWordInfo()) {
|
if (!ptNodeParams.representsNonWordInfo()) {
|
||||||
mUnigramCount--;
|
mUnigramCount--;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue