aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-04-23 15:37:07 +0900
committerJean Chalard <jchalard@google.com>2012-04-23 16:05:36 +0900
commit522a04ea5b249d0af556647d2abcad57e5b99b4f (patch)
tree7bb086debeed66c3b2fd32137db9b2586532026f /native/jni/src
parent0df78d46da1ef0d42196f3baa9d5f6df5932afb6 (diff)
downloadlatinime-522a04ea5b249d0af556647d2abcad57e5b99b4f.tar.gz
latinime-522a04ea5b249d0af556647d2abcad57e5b99b4f.tar.xz
latinime-522a04ea5b249d0af556647d2abcad57e5b99b4f.zip
Pass words as int[] to the native code.
We need to get the bigrams during the call to getSuggestions for bug#6313806. We already give an int[] to getSuggestions and we wanted to get rid of char[]'s anyway because it doesn't work with surrogate pairs, so here we go. Bug: 6313806 Change-Id: I56ce99f1db6b3302cdf42f0527343bded837091e
Diffstat (limited to 'native/jni/src')
-rw-r--r--native/jni/src/bigram_dictionary.cpp4
-rw-r--r--native/jni/src/bigram_dictionary.h4
-rw-r--r--native/jni/src/binary_format.h6
-rw-r--r--native/jni/src/dictionary.cpp2
-rw-r--r--native/jni/src/dictionary.h4
-rw-r--r--native/jni/src/unigram_dictionary.cpp2
-rw-r--r--native/jni/src/unigram_dictionary.h2
7 files changed, 12 insertions, 12 deletions
diff --git a/native/jni/src/bigram_dictionary.cpp b/native/jni/src/bigram_dictionary.cpp
index 320b0af68..927381fdb 100644
--- a/native/jni/src/bigram_dictionary.cpp
+++ b/native/jni/src/bigram_dictionary.cpp
@@ -96,7 +96,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
* and the bigrams are used to boost unigram result scores, it makes little sense to
* reduce their scope to the ones that match the first letter.
*/
-int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, int *codes,
+int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, int *codes,
int codesSize, unsigned short *bigramChars, int *bigramFreq, int maxWordLength,
int maxBigrams) {
// TODO: remove unused arguments, and refrain from storing stuff in members of this class
@@ -134,7 +134,7 @@ int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, i
// Returns a pointer to the start of the bigram list.
// If the word is not found or has no bigrams, this function returns 0.
int BigramDictionary::getBigramListForWord(const uint8_t* const root,
- const unsigned short *prevWord, const int prevWordLength) {
+ const int32_t *prevWord, const int prevWordLength) {
int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength);
if (NOT_VALID_WORD == pos) return 0;
diff --git a/native/jni/src/bigram_dictionary.h b/native/jni/src/bigram_dictionary.h
index 1612131c4..07e47f059 100644
--- a/native/jni/src/bigram_dictionary.h
+++ b/native/jni/src/bigram_dictionary.h
@@ -25,10 +25,10 @@ class Dictionary;
class BigramDictionary {
public:
BigramDictionary(const unsigned char *dict, int maxWordLength, Dictionary *parentDictionary);
- int getBigrams(unsigned short *word, int length, int *codes, int codesSize,
+ int getBigrams(const int32_t *word, int length, int *codes, int codesSize,
unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams);
int getBigramListForWord(const uint8_t* const root,
- const unsigned short *prevWord, const int prevWordLength);
+ const int32_t *prevWord, const int prevWordLength);
~BigramDictionary();
private:
bool addWordBigram(unsigned short *word, int length, int frequency);
diff --git a/native/jni/src/binary_format.h b/native/jni/src/binary_format.h
index f59302460..b8ac95250 100644
--- a/native/jni/src/binary_format.h
+++ b/native/jni/src/binary_format.h
@@ -62,7 +62,7 @@ class BinaryFormat {
static bool hasChildrenInFlags(const uint8_t flags);
static int getAttributeAddressAndForwardPointer(const uint8_t* const dict, const uint8_t flags,
int *pos);
- static int getTerminalPosition(const uint8_t* const root, const uint16_t* const inWord,
+ static int getTerminalPosition(const uint8_t* const root, const int32_t* const inWord,
const int length);
static int getWordAtAddress(const uint8_t* const root, const int address, const int maxDepth,
uint16_t* outWord);
@@ -304,7 +304,7 @@ inline int BinaryFormat::getAttributeAddressAndForwardPointer(const uint8_t* con
// This function gets the byte position of the last chargroup of the exact matching word in the
// dictionary. If no match is found, it returns NOT_VALID_WORD.
inline int BinaryFormat::getTerminalPosition(const uint8_t* const root,
- const uint16_t* const inWord, const int length) {
+ const int32_t* const inWord, const int length) {
int pos = 0;
int wordPos = 0;
@@ -313,7 +313,7 @@ inline int BinaryFormat::getTerminalPosition(const uint8_t* const root,
// there was no match (or we would have found it).
if (wordPos > length) return NOT_VALID_WORD;
int charGroupCount = BinaryFormat::getGroupCountAndForwardPointer(root, &pos);
- const uint16_t wChar = inWord[wordPos];
+ const int32_t wChar = inWord[wordPos];
while (true) {
// If there are no more character groups in this node, it means we could not
// find a matching character for this depth, therefore there is no match.
diff --git a/native/jni/src/dictionary.cpp b/native/jni/src/dictionary.cpp
index 90ec207f0..9dc207223 100644
--- a/native/jni/src/dictionary.cpp
+++ b/native/jni/src/dictionary.cpp
@@ -54,7 +54,7 @@ Dictionary::~Dictionary() {
delete mBigramDictionary;
}
-bool Dictionary::isValidWord(unsigned short *word, int length) {
+bool Dictionary::isValidWord(const int32_t *word, int length) {
return mUnigramDictionary->isValidWord(word, length);
}
diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h
index 66a5c2150..dea5763d0 100644
--- a/native/jni/src/dictionary.h
+++ b/native/jni/src/dictionary.h
@@ -40,13 +40,13 @@ class Dictionary {
codesSize, useFullEditDistance, outWords, frequencies);
}
- int getBigrams(unsigned short *word, int length, int *codes, int codesSize,
+ int getBigrams(const int32_t *word, int length, int *codes, int codesSize,
unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams) {
return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies,
maxWordLength, maxBigrams);
}
- bool isValidWord(unsigned short *word, int length);
+ bool isValidWord(const int32_t *word, int length);
void *getDict() { return (void *)mDict; }
int getDictSize() { return mDictSize; }
int getMmapFd() { return mMmapFd; }
diff --git a/native/jni/src/unigram_dictionary.cpp b/native/jni/src/unigram_dictionary.cpp
index ab8570e6f..05c124b94 100644
--- a/native/jni/src/unigram_dictionary.cpp
+++ b/native/jni/src/unigram_dictionary.cpp
@@ -730,7 +730,7 @@ int UnigramDictionary::getMostFrequentWordLikeInner(const uint16_t * const inWor
return maxFreq;
}
-bool UnigramDictionary::isValidWord(const uint16_t* const inWord, const int length) const {
+bool UnigramDictionary::isValidWord(const int32_t* const inWord, const int length) const {
return NOT_VALID_WORD != BinaryFormat::getTerminalPosition(DICT_ROOT, inWord, length);
}
diff --git a/native/jni/src/unigram_dictionary.h b/native/jni/src/unigram_dictionary.h
index 4479cd94e..b09c0006d 100644
--- a/native/jni/src/unigram_dictionary.h
+++ b/native/jni/src/unigram_dictionary.h
@@ -71,7 +71,7 @@ class UnigramDictionary {
UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultipler,
int fullWordMultiplier, int maxWordLength, int maxWords, const unsigned int flags);
- bool isValidWord(const uint16_t* const inWord, const int length) const;
+ bool isValidWord(const int32_t* const inWord, const int length) const;
int getBigramPosition(int pos, unsigned short *word, int offset, int length) const;
int getSuggestions(ProximityInfo *proximityInfo, WordsPriorityQueuePool *queuePool,
Correction *correction, const int *xcoordinates,