am 1ca9f125: am 68719909: am 4a1ed92e: Merge "Remove getBigramsIteratorOfPtNode from structure policy." into lmp-dev
* commit '1ca9f125a5edf2a30f9e08d8a8754890e9865124': Remove getBigramsIteratorOfPtNode from structure policy.main
commit
188df1d7cf
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
class DictionaryBigramsStructurePolicy;
|
|
||||||
class DictionaryShortcutsStructurePolicy;
|
class DictionaryShortcutsStructurePolicy;
|
||||||
class PtNodeArrayReader;
|
class PtNodeArrayReader;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue