Remove getBigramsIteratorOfPtNode from structure policy.

Bug: 14425059
Change-Id: I427fbfd026c1e33b5e9cf78949fe862d8748b7ec
Keisuke Kuroyanagi 2014-07-31 12:27:21 +09:00
parent 35c62b2cc9
commit 0e6a1d1020
8 changed files with 12 additions and 38 deletions

View File

@ -20,14 +20,12 @@
#include <memory> #include <memory>
#include "defines.h" #include "defines.h"
#include "suggest/core/dictionary/binary_dictionary_bigrams_iterator.h"
#include "suggest/core/dictionary/property/word_property.h" #include "suggest/core/dictionary/property/word_property.h"
namespace latinime { namespace latinime {
class DicNode; class DicNode;
class DicNodeVector; class DicNodeVector;
class DictionaryBigramsStructurePolicy;
class DictionaryHeaderStructurePolicy; class DictionaryHeaderStructurePolicy;
class DictionaryShortcutsStructurePolicy; class DictionaryShortcutsStructurePolicy;
class NgramListener; class NgramListener;
@ -67,8 +65,6 @@ class DictionaryStructureWithBufferPolicy {
virtual int getShortcutPositionOfPtNode(const int nodePos) const = 0; virtual int getShortcutPositionOfPtNode(const int nodePos) const = 0;
virtual BinaryDictionaryBigramsIterator getBigramsIteratorOfPtNode(const int nodePos) const = 0;
virtual const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const = 0; virtual const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const = 0;
virtual const DictionaryShortcutsStructurePolicy *getShortcutsStructurePolicy() const = 0; virtual const DictionaryShortcutsStructurePolicy *getShortcutsStructurePolicy() const = 0;

View File

@ -142,8 +142,8 @@ int Ver4PatriciaTriePolicy::getProbabilityOfPtNode(const int *const prevWordsPtN
return NOT_A_PROBABILITY; return NOT_A_PROBABILITY;
} }
if (prevWordsPtNodePos) { if (prevWordsPtNodePos) {
BinaryDictionaryBigramsIterator bigramsIt = const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]); BinaryDictionaryBigramsIterator bigramsIt(&mBigramPolicy, bigramsPosition);
while (bigramsIt.hasNext()) { while (bigramsIt.hasNext()) {
bigramsIt.next(); bigramsIt.next();
if (bigramsIt.getBigramPos() == ptNodePos if (bigramsIt.getBigramPos() == ptNodePos
@ -161,7 +161,8 @@ void Ver4PatriciaTriePolicy::iterateNgramEntries(const int *const prevWordsPtNod
if (!prevWordsPtNodePos) { if (!prevWordsPtNodePos) {
return; return;
} }
BinaryDictionaryBigramsIterator bigramsIt = getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]); const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
BinaryDictionaryBigramsIterator bigramsIt(&mBigramPolicy, bigramsPosition);
while (bigramsIt.hasNext()) { while (bigramsIt.hasNext()) {
bigramsIt.next(); bigramsIt.next();
listener->onVisitEntry(bigramsIt.getProbability(), bigramsIt.getBigramPos()); listener->onVisitEntry(bigramsIt.getProbability(), bigramsIt.getBigramPos());
@ -180,12 +181,6 @@ int Ver4PatriciaTriePolicy::getShortcutPositionOfPtNode(const int ptNodePos) con
ptNodeParams.getTerminalId()); ptNodeParams.getTerminalId());
} }
BinaryDictionaryBigramsIterator Ver4PatriciaTriePolicy::getBigramsIteratorOfPtNode(
const int ptNodePos) const {
const int bigramsPosition = getBigramsPositionOfPtNode(ptNodePos);
return BinaryDictionaryBigramsIterator(&mBigramPolicy, bigramsPosition);
}
int Ver4PatriciaTriePolicy::getBigramsPositionOfPtNode(const int ptNodePos) const { int Ver4PatriciaTriePolicy::getBigramsPositionOfPtNode(const int ptNodePos) const {
if (ptNodePos == NOT_A_DICT_POS) { if (ptNodePos == NOT_A_DICT_POS) {
return NOT_A_DICT_POS; return NOT_A_DICT_POS;

View File

@ -97,8 +97,6 @@ class Ver4PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy {
int getShortcutPositionOfPtNode(const int ptNodePos) const; int getShortcutPositionOfPtNode(const int ptNodePos) const;
BinaryDictionaryBigramsIterator getBigramsIteratorOfPtNode(const int ptNodePos) const;
const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const { const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const {
return mHeaderPolicy; return mHeaderPolicy;
} }

View File

@ -26,7 +26,6 @@
namespace latinime { namespace latinime {
class DictionaryBigramsStructurePolicy;
class DictionaryShortcutsStructurePolicy; class DictionaryShortcutsStructurePolicy;
class PtNodeArrayReader; class PtNodeArrayReader;

View File

@ -311,8 +311,8 @@ int PatriciaTriePolicy::getProbabilityOfPtNode(const int *const prevWordsPtNodeP
return NOT_A_PROBABILITY; return NOT_A_PROBABILITY;
} }
if (prevWordsPtNodePos) { if (prevWordsPtNodePos) {
BinaryDictionaryBigramsIterator bigramsIt = const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]); BinaryDictionaryBigramsIterator bigramsIt(&mBigramListPolicy, bigramsPosition);
while (bigramsIt.hasNext()) { while (bigramsIt.hasNext()) {
bigramsIt.next(); bigramsIt.next();
if (bigramsIt.getBigramPos() == ptNodePos if (bigramsIt.getBigramPos() == ptNodePos
@ -330,7 +330,8 @@ void PatriciaTriePolicy::iterateNgramEntries(const int *const prevWordsPtNodePos
if (!prevWordsPtNodePos) { if (!prevWordsPtNodePos) {
return; return;
} }
BinaryDictionaryBigramsIterator bigramsIt = getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]); const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
BinaryDictionaryBigramsIterator bigramsIt(&mBigramListPolicy, bigramsPosition);
while (bigramsIt.hasNext()) { while (bigramsIt.hasNext()) {
bigramsIt.next(); bigramsIt.next();
listener->onVisitEntry(bigramsIt.getProbability(), bigramsIt.getBigramPos()); listener->onVisitEntry(bigramsIt.getProbability(), bigramsIt.getBigramPos());
@ -344,12 +345,6 @@ int PatriciaTriePolicy::getShortcutPositionOfPtNode(const int ptNodePos) const {
return mPtNodeReader.fetchPtNodeParamsInBufferFromPtNodePos(ptNodePos).getShortcutPos(); return mPtNodeReader.fetchPtNodeParamsInBufferFromPtNodePos(ptNodePos).getShortcutPos();
} }
BinaryDictionaryBigramsIterator PatriciaTriePolicy::getBigramsIteratorOfPtNode(
const int ptNodePos) const {
const int bigramsPosition = getBigramsPositionOfPtNode(ptNodePos);
return BinaryDictionaryBigramsIterator(&mBigramListPolicy, bigramsPosition);
}
int PatriciaTriePolicy::getBigramsPositionOfPtNode(const int ptNodePos) const { int PatriciaTriePolicy::getBigramsPositionOfPtNode(const int ptNodePos) const {
if (ptNodePos == NOT_A_DICT_POS) { if (ptNodePos == NOT_A_DICT_POS) {
return NOT_A_DICT_POS; return NOT_A_DICT_POS;

View File

@ -70,8 +70,6 @@ class PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy {
int getShortcutPositionOfPtNode(const int ptNodePos) const; int getShortcutPositionOfPtNode(const int ptNodePos) const;
BinaryDictionaryBigramsIterator getBigramsIteratorOfPtNode(const int ptNodePos) const;
const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const { const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const {
return &mHeaderPolicy; return &mHeaderPolicy;
} }

View File

@ -132,8 +132,8 @@ int Ver4PatriciaTriePolicy::getProbabilityOfPtNode(const int *const prevWordsPtN
return NOT_A_PROBABILITY; return NOT_A_PROBABILITY;
} }
if (prevWordsPtNodePos) { if (prevWordsPtNodePos) {
BinaryDictionaryBigramsIterator bigramsIt = const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]); BinaryDictionaryBigramsIterator bigramsIt(&mBigramPolicy, bigramsPosition);
while (bigramsIt.hasNext()) { while (bigramsIt.hasNext()) {
bigramsIt.next(); bigramsIt.next();
if (bigramsIt.getBigramPos() == ptNodePos if (bigramsIt.getBigramPos() == ptNodePos
@ -151,7 +151,8 @@ void Ver4PatriciaTriePolicy::iterateNgramEntries(const int *const prevWordsPtNod
if (!prevWordsPtNodePos) { if (!prevWordsPtNodePos) {
return; return;
} }
BinaryDictionaryBigramsIterator bigramsIt = getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]); const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
BinaryDictionaryBigramsIterator bigramsIt(&mBigramPolicy, bigramsPosition);
while (bigramsIt.hasNext()) { while (bigramsIt.hasNext()) {
bigramsIt.next(); bigramsIt.next();
listener->onVisitEntry(bigramsIt.getProbability(), bigramsIt.getBigramPos()); listener->onVisitEntry(bigramsIt.getProbability(), bigramsIt.getBigramPos());
@ -170,12 +171,6 @@ int Ver4PatriciaTriePolicy::getShortcutPositionOfPtNode(const int ptNodePos) con
ptNodeParams.getTerminalId()); ptNodeParams.getTerminalId());
} }
BinaryDictionaryBigramsIterator Ver4PatriciaTriePolicy::getBigramsIteratorOfPtNode(
const int ptNodePos) const {
const int bigramsPosition = getBigramsPositionOfPtNode(ptNodePos);
return BinaryDictionaryBigramsIterator(&mBigramPolicy, bigramsPosition);
}
int Ver4PatriciaTriePolicy::getBigramsPositionOfPtNode(const int ptNodePos) const { int Ver4PatriciaTriePolicy::getBigramsPositionOfPtNode(const int ptNodePos) const {
if (ptNodePos == NOT_A_DICT_POS) { if (ptNodePos == NOT_A_DICT_POS) {
return NOT_A_DICT_POS; return NOT_A_DICT_POS;

View File

@ -79,8 +79,6 @@ class Ver4PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy {
int getShortcutPositionOfPtNode(const int ptNodePos) const; int getShortcutPositionOfPtNode(const int ptNodePos) const;
BinaryDictionaryBigramsIterator getBigramsIteratorOfPtNode(const int ptNodePos) const;
const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const { const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const {
return mHeaderPolicy; return mHeaderPolicy;
} }