Breakdown getWordRec
Change-Id: I4fef02c227fb858334dbe2eabf2762d5b6e1d919
diff --git a/native/src/dictionary.h b/native/src/dictionary.h
index 1cd517c..da87624 100644
--- a/native/src/dictionary.h
+++ b/native/src/dictionary.h
@@ -54,6 +54,10 @@
static int getAddress(const unsigned char *dict, int *pos);
static int getFreq(const unsigned char *dict, const bool isLatestDictVersion, int *pos);
static int wideStrLen(unsigned short *str);
+ // returns next sibling's position
+ static int setDictionaryValues(const unsigned char *dict, const bool isLatestDictVersion,
+ const int pos, unsigned short *c, int *childrenPosition,
+ bool *terminal, int *freq);
private:
bool hasBigram();
@@ -127,5 +131,20 @@
return end - str;
}
+inline int Dictionary::setDictionaryValues(const unsigned char *dict,
+ const bool isLatestDictVersion, const int pos, unsigned short *c,int *childrenPosition,
+ bool *terminal, int *freq) {
+ int position = pos;
+ // -- at char
+ *c = Dictionary::getChar(dict, &position);
+ // -- at flag/add
+ *terminal = Dictionary::getTerminal(dict, &position);
+ *childrenPosition = Dictionary::getAddress(dict, &position);
+ // -- after address or flag
+ *freq = (*terminal) ? Dictionary::getFreq(dict, isLatestDictVersion, &position) : 1;
+ // returns next sibling's position
+ return position;
+}
+
}; // namespace latinime
#endif // LATINIME_DICTIONARY_H