mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Support removing n-gram entry in structure policy.
Bug: 14425059 Change-Id: Ifd2ac97a15dcbb936e2f068866a9d1ee68759ba2
This commit is contained in:
parent
0c0b8207cd
commit
5520e84e16
@ -232,11 +232,9 @@ bool Ver4PatriciaTrieNodeWriter::addNgramEntry(const WordIdArrayView prevWordIds
|
||||
|
||||
bool Ver4PatriciaTrieNodeWriter::removeNgramEntry(const WordIdArrayView prevWordIds,
|
||||
const int wordId) {
|
||||
// TODO: Support n-gram.
|
||||
LanguageModelDictContent *const languageModelDictContent =
|
||||
mBuffers->getMutableLanguageModelDictContent();
|
||||
return languageModelDictContent->removeNgramProbabilityEntry(prevWordIds.limit(1 /* maxSize */),
|
||||
wordId);
|
||||
return languageModelDictContent->removeNgramProbabilityEntry(prevWordIds, wordId);
|
||||
}
|
||||
|
||||
// TODO: Remove when we stop supporting v402 format.
|
||||
|
@ -375,15 +375,7 @@ bool Ver4PatriciaTriePolicy::removeNgramEntry(const PrevWordsInfo *const prevWor
|
||||
if (wordId == NOT_A_WORD_ID) {
|
||||
return false;
|
||||
}
|
||||
std::array<int, MAX_PREV_WORD_COUNT_FOR_N_GRAM> prevWordsPtNodePos;
|
||||
for (size_t i = 0; i < prevWordsPtNodePos.size(); ++i) {
|
||||
prevWordsPtNodePos[i] = mBuffers->getTerminalPositionLookupTable()
|
||||
->getTerminalPtNodePosition(prevWordIds[i]);
|
||||
}
|
||||
const int wordPtNodePos = mBuffers->getTerminalPositionLookupTable()
|
||||
->getTerminalPtNodePosition(wordId);
|
||||
if (mUpdatingHelper.removeNgramEntry(WordIdArrayView::fromArray(prevWordsPtNodePos),
|
||||
wordPtNodePos)) {
|
||||
if (mNodeWriter.removeNgramEntry(prevWordIds, wordId)) {
|
||||
mBigramCount--;
|
||||
return true;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user