Merge "Use emplace_back in getWordProperty()."
commit
e7ddf49d50
|
@ -349,14 +349,14 @@ const WordProperty PatriciaTriePolicy::getWordProperty(const int *const codePoin
|
||||||
// Skip the entry if the entry has been deleted. This never happens for ver2 dicts.
|
// Skip the entry if the entry has been deleted. This never happens for ver2 dicts.
|
||||||
if (bigramsIt.getBigramPos() != NOT_A_DICT_POS) {
|
if (bigramsIt.getBigramPos() != NOT_A_DICT_POS) {
|
||||||
int word1Probability = NOT_A_PROBABILITY;
|
int word1Probability = NOT_A_PROBABILITY;
|
||||||
int word1CodePointCount = getCodePointsAndProbabilityAndReturnCodePointCount(
|
const int word1CodePointCount = getCodePointsAndProbabilityAndReturnCodePointCount(
|
||||||
bigramsIt.getBigramPos(), MAX_WORD_LENGTH, bigramWord1CodePoints,
|
bigramsIt.getBigramPos(), MAX_WORD_LENGTH, bigramWord1CodePoints,
|
||||||
&word1Probability);
|
&word1Probability);
|
||||||
std::vector<int> word1(bigramWord1CodePoints,
|
const std::vector<int> word1(bigramWord1CodePoints,
|
||||||
bigramWord1CodePoints + word1CodePointCount);
|
bigramWord1CodePoints + word1CodePointCount);
|
||||||
const int probability = getProbability(word1Probability, bigramsIt.getProbability());
|
const int probability = getProbability(word1Probability, bigramsIt.getProbability());
|
||||||
bigrams.push_back(WordProperty::BigramProperty(&word1, probability,
|
bigrams.emplace_back(&word1, probability,
|
||||||
NOT_A_TIMESTAMP /* timestamp */, 0 /* level */, 0 /* count */));
|
NOT_A_TIMESTAMP /* timestamp */, 0 /* level */, 0 /* count */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fetch shortcut information.
|
// Fetch shortcut information.
|
||||||
|
@ -372,12 +372,11 @@ const WordProperty PatriciaTriePolicy::getWordProperty(const int *const codePoin
|
||||||
hasNext = ShortcutListReadingUtils::hasNext(shortcutFlags);
|
hasNext = ShortcutListReadingUtils::hasNext(shortcutFlags);
|
||||||
const int shortcutTargetLength = ShortcutListReadingUtils::readShortcutTarget(
|
const int shortcutTargetLength = ShortcutListReadingUtils::readShortcutTarget(
|
||||||
mDictRoot, MAX_WORD_LENGTH, shortcutTargetCodePoints, &shortcutPos);
|
mDictRoot, MAX_WORD_LENGTH, shortcutTargetCodePoints, &shortcutPos);
|
||||||
std::vector<int> shortcutTarget(shortcutTargetCodePoints,
|
const std::vector<int> shortcutTarget(shortcutTargetCodePoints,
|
||||||
shortcutTargetCodePoints + shortcutTargetLength);
|
shortcutTargetCodePoints + shortcutTargetLength);
|
||||||
const int shortcutProbability =
|
const int shortcutProbability =
|
||||||
ShortcutListReadingUtils::getProbabilityFromFlags(shortcutFlags);
|
ShortcutListReadingUtils::getProbabilityFromFlags(shortcutFlags);
|
||||||
shortcuts.push_back(
|
shortcuts.emplace_back(&shortcutTarget, shortcutProbability);
|
||||||
WordProperty::ShortcutProperty(&shortcutTarget, shortcutProbability));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return WordProperty(&codePointVector, ptNodeParams.isNotAWord(),
|
return WordProperty(&codePointVector, ptNodeParams.isNotAWord(),
|
||||||
|
|
|
@ -382,16 +382,16 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(const int *const code
|
||||||
const int codePointCount = getCodePointsAndProbabilityAndReturnCodePointCount(
|
const int codePointCount = getCodePointsAndProbabilityAndReturnCodePointCount(
|
||||||
word1TerminalPtNodePos, MAX_WORD_LENGTH, bigramWord1CodePoints,
|
word1TerminalPtNodePos, MAX_WORD_LENGTH, bigramWord1CodePoints,
|
||||||
&word1Probability);
|
&word1Probability);
|
||||||
std::vector<int> word1(bigramWord1CodePoints,
|
const std::vector<int> word1(bigramWord1CodePoints,
|
||||||
bigramWord1CodePoints + codePointCount);
|
bigramWord1CodePoints + codePointCount);
|
||||||
const HistoricalInfo *const historicalInfo = bigramEntry.getHistoricalInfo();
|
const HistoricalInfo *const historicalInfo = bigramEntry.getHistoricalInfo();
|
||||||
const int probability = bigramEntry.hasHistoricalInfo() ?
|
const int probability = bigramEntry.hasHistoricalInfo() ?
|
||||||
ForgettingCurveUtils::decodeProbability(
|
ForgettingCurveUtils::decodeProbability(
|
||||||
bigramEntry.getHistoricalInfo(), mHeaderPolicy) :
|
bigramEntry.getHistoricalInfo(), mHeaderPolicy) :
|
||||||
getProbability(word1Probability, bigramEntry.getProbability());
|
getProbability(word1Probability, bigramEntry.getProbability());
|
||||||
bigrams.push_back(WordProperty::BigramProperty(&word1, probability,
|
bigrams.emplace_back(&word1, probability,
|
||||||
historicalInfo->getTimeStamp(), historicalInfo->getLevel(),
|
historicalInfo->getTimeStamp(), historicalInfo->getLevel(),
|
||||||
historicalInfo->getCount()));
|
historicalInfo->getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fetch shortcut information.
|
// Fetch shortcut information.
|
||||||
|
@ -407,8 +407,8 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(const int *const code
|
||||||
int shortcutProbability = NOT_A_PROBABILITY;
|
int shortcutProbability = NOT_A_PROBABILITY;
|
||||||
shortcutDictContent->getShortcutEntryAndAdvancePosition(MAX_WORD_LENGTH, shortcutTarget,
|
shortcutDictContent->getShortcutEntryAndAdvancePosition(MAX_WORD_LENGTH, shortcutTarget,
|
||||||
&shortcutTargetLength, &shortcutProbability, &hasNext, &shortcutPos);
|
&shortcutTargetLength, &shortcutProbability, &hasNext, &shortcutPos);
|
||||||
std::vector<int> target(shortcutTarget, shortcutTarget + shortcutTargetLength);
|
const std::vector<int> target(shortcutTarget, shortcutTarget + shortcutTargetLength);
|
||||||
shortcuts.push_back(WordProperty::ShortcutProperty(&target, shortcutProbability));
|
shortcuts.emplace_back(&target, shortcutProbability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return WordProperty(&codePointVector, ptNodeParams.isNotAWord(),
|
return WordProperty(&codePointVector, ptNodeParams.isNotAWord(),
|
||||||
|
|
Loading…
Reference in New Issue