am b23f0348: Merge "Use reference instead of pointer for WordProperty()."
* commit 'b23f03488f165565e46f8d1b742ee6629f9c0f52': Use reference instead of pointer for WordProperty().main
commit
75825abc72
|
@ -586,7 +586,7 @@ static bool latinime_BinaryDictionary_migrateNative(JNIEnv *env, jclass clazz, j
|
|||
}
|
||||
if (!dictionaryStructureWithBufferPolicy->addUnigramEntry(
|
||||
CodePointArrayView(wordCodePoints, wordCodePointCount),
|
||||
wordProperty.getUnigramProperty())) {
|
||||
&wordProperty.getUnigramProperty())) {
|
||||
LogUtils::logToJava(env, "Cannot add unigram to the new dict.");
|
||||
return false;
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ static bool latinime_BinaryDictionary_migrateNative(JNIEnv *env, jclass clazz, j
|
|||
return false;
|
||||
}
|
||||
}
|
||||
for (const NgramProperty &ngramProperty : *wordProperty.getNgramProperties()) {
|
||||
for (const NgramProperty &ngramProperty : wordProperty.getNgramProperties()) {
|
||||
if (!dictionaryStructureWithBufferPolicy->addNgramEntry(&ngramProperty)) {
|
||||
LogUtils::logToJava(env, "Cannot add ngram to the new dict.");
|
||||
return false;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "jni.h"
|
||||
#include "suggest/core/dictionary/property/ngram_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(), mNgrams() {}
|
||||
|
||||
WordProperty(const std::vector<int> &&codePoints, const UnigramProperty *const unigramProperty,
|
||||
const std::vector<NgramProperty> *const ngrams)
|
||||
: mCodePoints(std::move(codePoints)), mUnigramProperty(*unigramProperty),
|
||||
mNgrams(*ngrams) {}
|
||||
WordProperty(const std::vector<int> &&codePoints, const UnigramProperty &unigramProperty,
|
||||
const std::vector<NgramProperty> &ngrams)
|
||||
: mCodePoints(std::move(codePoints)), mUnigramProperty(unigramProperty),
|
||||
mNgrams(ngrams) {}
|
||||
|
||||
void outputProperties(JNIEnv *const env, jintArray outCodePoints, jbooleanArray outFlags,
|
||||
jintArray outProbabilityInfo, jobject outNgramPrevWordsArray,
|
||||
|
@ -44,12 +45,16 @@ class WordProperty {
|
|||
jobject outNgramProbabilities, jobject outShortcutTargets,
|
||||
jobject outShortcutProbabilities) const;
|
||||
|
||||
const UnigramProperty *getUnigramProperty() const {
|
||||
return &mUnigramProperty;
|
||||
const CodePointArrayView getCodePoints() const {
|
||||
return CodePointArrayView(mCodePoints);
|
||||
}
|
||||
|
||||
const std::vector<NgramProperty> *getNgramProperties() const {
|
||||
return &mNgrams;
|
||||
const UnigramProperty &getUnigramProperty() const {
|
||||
return mUnigramProperty;
|
||||
}
|
||||
|
||||
const std::vector<NgramProperty> &getNgramProperties() const {
|
||||
return mNgrams;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -614,7 +614,7 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(
|
|||
const UnigramProperty unigramProperty(ptNodeParams.representsBeginningOfSentence(),
|
||||
ptNodeParams.isNotAWord(), ptNodeParams.isPossiblyOffensive(),
|
||||
ptNodeParams.getProbability(), *historicalInfo, std::move(shortcuts));
|
||||
return WordProperty(wordCodePoints.toVector(), &unigramProperty, &ngrams);
|
||||
return WordProperty(wordCodePoints.toVector(), unigramProperty, ngrams);
|
||||
}
|
||||
|
||||
int Ver4PatriciaTriePolicy::getNextWordAndNextToken(const int token, int *const outCodePoints,
|
||||
|
|
|
@ -478,7 +478,7 @@ const WordProperty PatriciaTriePolicy::getWordProperty(
|
|||
const UnigramProperty unigramProperty(ptNodeParams.representsBeginningOfSentence(),
|
||||
ptNodeParams.isNotAWord(), ptNodeParams.isPossiblyOffensive(),
|
||||
ptNodeParams.getProbability(), HistoricalInfo(), std::move(shortcuts));
|
||||
return WordProperty(wordCodePoints.toVector(), &unigramProperty, &ngrams);
|
||||
return WordProperty(wordCodePoints.toVector(), unigramProperty, ngrams);
|
||||
}
|
||||
|
||||
int PatriciaTriePolicy::getNextWordAndNextToken(const int token, int *const outCodePoints,
|
||||
|
|
|
@ -560,7 +560,7 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(
|
|||
wordAttributes.isNotAWord(), wordAttributes.isBlacklisted(),
|
||||
wordAttributes.isPossiblyOffensive(), wordAttributes.getProbability(),
|
||||
*historicalInfo, std::move(shortcuts));
|
||||
return WordProperty(wordCodePoints.toVector(), &unigramProperty, &ngrams);
|
||||
return WordProperty(wordCodePoints.toVector(), unigramProperty, ngrams);
|
||||
}
|
||||
|
||||
int Ver4PatriciaTriePolicy::getNextWordAndNextToken(const int token, int *const outCodePoints,
|
||||
|
|
Loading…
Reference in New Issue