am da7aab8e: Merge "Fix: native crash while iterating bigramslist."
* commit 'da7aab8e2602eac36407830de6c8dca1643a122e': Fix: native crash while iterating bigramslist.main
commit
ae10e2c170
|
@ -120,8 +120,8 @@ int BigramDictionary::getPredictions(const int *prevWord, int prevWordLength, in
|
||||||
int bigramCount = 0;
|
int bigramCount = 0;
|
||||||
int unigramProbability = 0;
|
int unigramProbability = 0;
|
||||||
int bigramBuffer[MAX_WORD_LENGTH];
|
int bigramBuffer[MAX_WORD_LENGTH];
|
||||||
for (BinaryDictionaryBigramsIterator bigramsIt(mBinaryDictionaryInfo, pos);
|
BinaryDictionaryBigramsIterator bigramsIt(mBinaryDictionaryInfo, pos);
|
||||||
bigramsIt.hasNext(); /* no-op */) {
|
while (bigramsIt.hasNext()) {
|
||||||
bigramsIt.next();
|
bigramsIt.next();
|
||||||
const int length = mBinaryDictionaryInfo->getStructurePolicy()->
|
const int length = mBinaryDictionaryInfo->getStructurePolicy()->
|
||||||
getCodePointsAndProbabilityAndReturnCodePointCount(
|
getCodePointsAndProbabilityAndReturnCodePointCount(
|
||||||
|
@ -147,13 +147,13 @@ int BigramDictionary::getPredictions(const int *prevWord, int prevWordLength, in
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a pointer to the start of the bigram list.
|
// Returns a pointer to the start of the bigram list.
|
||||||
// If the word is not found or has no bigrams, this function returns 0.
|
// If the word is not found or has no bigrams, this function returns NOT_A_DICT_POS.
|
||||||
int BigramDictionary::getBigramListPositionForWord(const int *prevWord, const int prevWordLength,
|
int BigramDictionary::getBigramListPositionForWord(const int *prevWord, const int prevWordLength,
|
||||||
const bool forceLowerCaseSearch) const {
|
const bool forceLowerCaseSearch) const {
|
||||||
if (0 >= prevWordLength) return 0;
|
if (0 >= prevWordLength) return NOT_A_DICT_POS;
|
||||||
int pos = mBinaryDictionaryInfo->getStructurePolicy()->getTerminalNodePositionOfWord(
|
int pos = mBinaryDictionaryInfo->getStructurePolicy()->getTerminalNodePositionOfWord(
|
||||||
mBinaryDictionaryInfo, prevWord, prevWordLength, forceLowerCaseSearch);
|
mBinaryDictionaryInfo, prevWord, prevWordLength, forceLowerCaseSearch);
|
||||||
if (NOT_A_VALID_WORD_POS == pos) return 0;
|
if (NOT_A_VALID_WORD_POS == pos) return NOT_A_DICT_POS;
|
||||||
return mBinaryDictionaryInfo->getStructurePolicy()->getBigramsPositionOfNode(
|
return mBinaryDictionaryInfo->getStructurePolicy()->getBigramsPositionOfNode(
|
||||||
mBinaryDictionaryInfo, pos);
|
mBinaryDictionaryInfo, pos);
|
||||||
}
|
}
|
||||||
|
@ -183,8 +183,8 @@ bool BigramDictionary::isValidBigram(const int *word0, int length0, const int *w
|
||||||
mBinaryDictionaryInfo, word1, length1, false /* forceLowerCaseSearch */);
|
mBinaryDictionaryInfo, word1, length1, false /* forceLowerCaseSearch */);
|
||||||
if (NOT_A_VALID_WORD_POS == nextWordPos) return false;
|
if (NOT_A_VALID_WORD_POS == nextWordPos) return false;
|
||||||
|
|
||||||
for (BinaryDictionaryBigramsIterator bigramsIt(mBinaryDictionaryInfo, pos);
|
BinaryDictionaryBigramsIterator bigramsIt(mBinaryDictionaryInfo, pos);
|
||||||
bigramsIt.hasNext(); /* no-op */) {
|
while (bigramsIt.hasNext()) {
|
||||||
bigramsIt.next();
|
bigramsIt.next();
|
||||||
if (bigramsIt.getBigramPos() == nextWordPos) {
|
if (bigramsIt.getBigramPos() == nextWordPos) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -69,8 +69,8 @@ class MultiBigramMap {
|
||||||
void init(const BinaryDictionaryInfo *const binaryDictionaryInfo, const int nodePos) {
|
void init(const BinaryDictionaryInfo *const binaryDictionaryInfo, const int nodePos) {
|
||||||
const int bigramsListPos = binaryDictionaryInfo->getStructurePolicy()->
|
const int bigramsListPos = binaryDictionaryInfo->getStructurePolicy()->
|
||||||
getBigramsPositionOfNode(binaryDictionaryInfo, nodePos);
|
getBigramsPositionOfNode(binaryDictionaryInfo, nodePos);
|
||||||
for (BinaryDictionaryBigramsIterator bigramsIt(binaryDictionaryInfo, bigramsListPos);
|
BinaryDictionaryBigramsIterator bigramsIt(binaryDictionaryInfo, bigramsListPos);
|
||||||
bigramsIt.hasNext(); /* no-op */) {
|
while (bigramsIt.hasNext()) {
|
||||||
bigramsIt.next();
|
bigramsIt.next();
|
||||||
mBigramMap[bigramsIt.getBigramPos()] = bigramsIt.getProbability();
|
mBigramMap[bigramsIt.getBigramPos()] = bigramsIt.getProbability();
|
||||||
mBloomFilter.setInFilter(bigramsIt.getBigramPos());
|
mBloomFilter.setInFilter(bigramsIt.getBigramPos());
|
||||||
|
@ -109,8 +109,8 @@ class MultiBigramMap {
|
||||||
const int nextWordPosition, const int unigramProbability) {
|
const int nextWordPosition, const int unigramProbability) {
|
||||||
const int bigramsListPos = binaryDictionaryInfo->getStructurePolicy()->
|
const int bigramsListPos = binaryDictionaryInfo->getStructurePolicy()->
|
||||||
getBigramsPositionOfNode(binaryDictionaryInfo, nodePos);
|
getBigramsPositionOfNode(binaryDictionaryInfo, nodePos);
|
||||||
for (BinaryDictionaryBigramsIterator bigramsIt(binaryDictionaryInfo, bigramsListPos);
|
BinaryDictionaryBigramsIterator bigramsIt(binaryDictionaryInfo, bigramsListPos);
|
||||||
bigramsIt.hasNext(); /* no-op */) {
|
while (bigramsIt.hasNext()) {
|
||||||
bigramsIt.next();
|
bigramsIt.next();
|
||||||
if (bigramsIt.getBigramPos() == nextWordPosition) {
|
if (bigramsIt.getBigramPos() == nextWordPosition) {
|
||||||
return ProbabilityUtils::computeProbabilityForBigram(
|
return ProbabilityUtils::computeProbabilityForBigram(
|
||||||
|
|
Loading…
Reference in New Issue