diff options
author | 2011-12-26 15:16:59 +0900 | |
---|---|---|
committer | 2012-01-06 12:24:30 +0900 | |
commit | cf9dbbdd1ade7cf1d05f3cb080018931aa540e61 (patch) | |
tree | 0e9ad9b77e909469165821ce46c5b74d67e03108 /native/src/unigram_dictionary.cpp | |
parent | 3b161b2526ee7f867c887462dc826d2edc118f3d (diff) | |
download | latinime-cf9dbbdd1ade7cf1d05f3cb080018931aa540e61.tar.gz latinime-cf9dbbdd1ade7cf1d05f3cb080018931aa540e61.tar.xz latinime-cf9dbbdd1ade7cf1d05f3cb080018931aa540e61.zip |
Add methods to read shortcuts from the binary dict (A2)
This contains stubs only, it does not work yet, however it
doesn't break anything.
Change-Id: If912ae84ff3ccd7a2d6588ffd6fbb9974f87ef3d
Diffstat (limited to 'native/src/unigram_dictionary.cpp')
-rw-r--r-- | native/src/unigram_dictionary.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp index 7c3c35e40..5dd4c7e21 100644 --- a/native/src/unigram_dictionary.cpp +++ b/native/src/unigram_dictionary.cpp @@ -25,6 +25,7 @@ #include "unigram_dictionary.h" #include "binary_format.h" +#include "terminal_attributes.h" namespace latinime { @@ -324,13 +325,21 @@ void UnigramDictionary::getMistypedSpaceWords(ProximityInfo *proximityInfo, cons correction, queuePool); } -inline void UnigramDictionary::onTerminal( - const int freq, Correction *correction, WordsPriorityQueue *queue) { +inline void UnigramDictionary::onTerminal(const int freq, + const TerminalAttributes& terminalAttributes, Correction *correction, + WordsPriorityQueue *queue) { int wordLength; unsigned short* wordPointer; const int finalFreq = correction->getFinalFreq(freq, &wordPointer, &wordLength); if (finalFreq >= 0) { - addWord(wordPointer, wordLength, finalFreq, queue); + if (!terminalAttributes.isShortcutOnly()) { + addWord(wordPointer, wordLength, finalFreq, queue); + } + TerminalAttributes::ShortcutIterator iterator = terminalAttributes.getShortcutIterator(); + while (iterator.hasNextShortcutTarget()) { + // TODO: add the shortcut to the list of suggestions using the + // iterator.getNextShortcutTarget(int, uint16_t*) method + } } } @@ -646,7 +655,9 @@ inline bool UnigramDictionary::processCurrentNode(const int initialPos, // The frequency should be here, because we come here only if this is actually // a terminal node, and we are on its last char. const int freq = BinaryFormat::readFrequencyWithoutMovingPointer(DICT_ROOT, pos); - onTerminal(freq, correction, queue); + TerminalAttributes terminalAttributes(DICT_ROOT, flags, + BinaryFormat::skipFrequency(flags, pos)); + onTerminal(freq, terminalAttributes, correction, queue); } // If there are more chars in this node, then this virtual node has children. |