AI 143659: am: CL 143472 Reduce dictionary size.
Changed the tree structure to have variable length nodes to save an average of 21% on the dictionary size.
Created a shortened English dictionary for Dream - 50K words.
Added a shortened Spanish dictionary for Dream - 32K words.
Original author: yamasani
Merged from: //branches/cupcake/...
Automated import of CL 143659
diff --git a/dictionary/src/dictionary.cpp b/dictionary/src/dictionary.cpp
index 6aecb63..b37f4c9 100644
--- a/dictionary/src/dictionary.cpp
+++ b/dictionary/src/dictionary.cpp
@@ -85,10 +85,14 @@
Dictionary::getAddress(int *pos)
{
int address = 0;
- address += (mDict[*pos] & 0x7F) << 16;
- address += (mDict[*pos + 1] & 0xFF) << 8;
- address += (mDict[*pos + 2] & 0xFF);
- *pos += 3;
+ if ((mDict[*pos] & FLAG_ADDRESS_MASK) == 0) {
+ *pos += 1;
+ } else {
+ address += (mDict[*pos] & (ADDRESS_MASK >> 16)) << 16;
+ address += (mDict[*pos + 1] & 0xFF) << 8;
+ address += (mDict[*pos + 2] & 0xFF);
+ *pos += 3;
+ }
return address;
}
@@ -193,7 +197,8 @@
unsigned short lowerC = toLowerCase(c, depth);
bool terminal = getTerminal(&pos);
int childrenAddress = getAddress(&pos);
- int freq = getFreq(&pos);
+ int freq = 1;
+ if (terminal) freq = getFreq(&pos);
// If we are only doing completions, no need to look at the typed characters.
if (completion) {
mWord[depth] = c;
@@ -266,7 +271,9 @@
}
}
}
- getFreq(&pos);
+ if (terminal) {
+ getFreq(&pos);
+ }
// There could be two instances of each alphabet - upper and lower case. So continue
// looking ...
}