am ed77b37e: Merge "Use CodePointArrayView in WordProperty."
* commit 'ed77b37e6b87d7296e21b42a28337ce6afa1ceec': Use CodePointArrayView in WordProperty.main
commit
1d371b7cbc
|
@ -23,6 +23,7 @@
|
|||
#include "jni.h"
|
||||
#include "suggest/core/dictionary/property/bigram_property.h"
|
||||
#include "suggest/core/dictionary/property/unigram_property.h"
|
||||
#include "utils/int_array_view.h"
|
||||
|
||||
namespace latinime {
|
||||
|
||||
|
@ -33,10 +34,10 @@ class WordProperty {
|
|||
WordProperty()
|
||||
: mCodePoints(), mUnigramProperty(), mBigrams() {}
|
||||
|
||||
WordProperty(const std::vector<int> *const codePoints,
|
||||
const UnigramProperty *const unigramProperty,
|
||||
WordProperty(const CodePointArrayView codePoints, const UnigramProperty *const unigramProperty,
|
||||
const std::vector<BigramProperty> *const bigrams)
|
||||
: mCodePoints(*codePoints), mUnigramProperty(*unigramProperty), mBigrams(*bigrams) {}
|
||||
: mCodePoints(codePoints.begin(), codePoints.end()), mUnigramProperty(*unigramProperty),
|
||||
mBigrams(*bigrams) {}
|
||||
|
||||
void outputProperties(JNIEnv *const env, jintArray outCodePoints, jbooleanArray outFlags,
|
||||
jintArray outProbabilityInfo, jobject outBigramTargets, jobject outBigramProbabilities,
|
||||
|
|
|
@ -494,8 +494,6 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(
|
|||
return WordProperty();
|
||||
}
|
||||
const PtNodeParams ptNodeParams = mNodeReader.fetchPtNodeParamsInBufferFromPtNodePos(ptNodePos);
|
||||
std::vector<int> codePointVector(ptNodeParams.getCodePoints(),
|
||||
ptNodeParams.getCodePoints() + ptNodeParams.getCodePointCount());
|
||||
const ProbabilityEntry probabilityEntry =
|
||||
mBuffers->getProbabilityDictContent()->getProbabilityEntry(
|
||||
ptNodeParams.getTerminalId());
|
||||
|
@ -556,7 +554,7 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(
|
|||
ptNodeParams.isNotAWord(), ptNodeParams.isBlacklisted(), ptNodeParams.getProbability(),
|
||||
historicalInfo->getTimeStamp(), historicalInfo->getLevel(),
|
||||
historicalInfo->getCount(), &shortcuts);
|
||||
return WordProperty(&codePointVector, &unigramProperty, &bigrams);
|
||||
return WordProperty(wordCodePoints, &unigramProperty, &bigrams);
|
||||
}
|
||||
|
||||
int Ver4PatriciaTriePolicy::getNextWordAndNextToken(const int token, int *const outCodePoints,
|
||||
|
|
|
@ -435,8 +435,6 @@ const WordProperty PatriciaTriePolicy::getWordProperty(
|
|||
const int ptNodePos = getTerminalPtNodePosFromWordId(wordId);
|
||||
const PtNodeParams ptNodeParams =
|
||||
mPtNodeReader.fetchPtNodeParamsInBufferFromPtNodePos(ptNodePos);
|
||||
std::vector<int> codePointVector(ptNodeParams.getCodePoints(),
|
||||
ptNodeParams.getCodePoints() + ptNodeParams.getCodePointCount());
|
||||
// Fetch bigram information.
|
||||
std::vector<BigramProperty> bigrams;
|
||||
const int bigramListPos = getBigramsPositionOfPtNode(ptNodePos);
|
||||
|
@ -481,7 +479,7 @@ const WordProperty PatriciaTriePolicy::getWordProperty(
|
|||
const UnigramProperty unigramProperty(ptNodeParams.representsBeginningOfSentence(),
|
||||
ptNodeParams.isNotAWord(), ptNodeParams.isBlacklisted(), ptNodeParams.getProbability(),
|
||||
NOT_A_TIMESTAMP /* timestamp */, 0 /* level */, 0 /* count */, &shortcuts);
|
||||
return WordProperty(&codePointVector, &unigramProperty, &bigrams);
|
||||
return WordProperty(wordCodePoints, &unigramProperty, &bigrams);
|
||||
}
|
||||
|
||||
int PatriciaTriePolicy::getNextWordAndNextToken(const int token, int *const outCodePoints,
|
||||
|
|
|
@ -451,8 +451,6 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(
|
|||
const int ptNodePos =
|
||||
mBuffers->getTerminalPositionLookupTable()->getTerminalPtNodePosition(wordId);
|
||||
const PtNodeParams ptNodeParams = mNodeReader.fetchPtNodeParamsInBufferFromPtNodePos(ptNodePos);
|
||||
std::vector<int> codePointVector(ptNodeParams.getCodePoints(),
|
||||
ptNodeParams.getCodePoints() + ptNodeParams.getCodePointCount());
|
||||
const ProbabilityEntry probabilityEntry =
|
||||
mBuffers->getLanguageModelDictContent()->getProbabilityEntry(
|
||||
ptNodeParams.getTerminalId());
|
||||
|
@ -498,7 +496,7 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(
|
|||
probabilityEntry.isNotAWord(), probabilityEntry.isBlacklisted(),
|
||||
probabilityEntry.getProbability(), historicalInfo->getTimeStamp(),
|
||||
historicalInfo->getLevel(), historicalInfo->getCount(), &shortcuts);
|
||||
return WordProperty(&codePointVector, &unigramProperty, &bigrams);
|
||||
return WordProperty(wordCodePoints, &unigramProperty, &bigrams);
|
||||
}
|
||||
|
||||
int Ver4PatriciaTriePolicy::getNextWordAndNextToken(const int token, int *const outCodePoints,
|
||||
|
|
Loading…
Reference in New Issue