Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a1ed92e authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by Android (Google) Code Review
Browse files

Merge "Remove getBigramsIteratorOfPtNode from structure policy." into lmp-dev

parents 211370a3 0e6a1d10
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -20,14 +20,12 @@
#include <memory>

#include "defines.h"
#include "suggest/core/dictionary/binary_dictionary_bigrams_iterator.h"
#include "suggest/core/dictionary/property/word_property.h"

namespace latinime {

class DicNode;
class DicNodeVector;
class DictionaryBigramsStructurePolicy;
class DictionaryHeaderStructurePolicy;
class DictionaryShortcutsStructurePolicy;
class NgramListener;
@@ -67,8 +65,6 @@ class DictionaryStructureWithBufferPolicy {

    virtual int getShortcutPositionOfPtNode(const int nodePos) const = 0;

    virtual BinaryDictionaryBigramsIterator getBigramsIteratorOfPtNode(const int nodePos) const = 0;

    virtual const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const = 0;

    virtual const DictionaryShortcutsStructurePolicy *getShortcutsStructurePolicy() const = 0;
+4 −9
Original line number Diff line number Diff line
@@ -142,8 +142,8 @@ int Ver4PatriciaTriePolicy::getProbabilityOfPtNode(const int *const prevWordsPtN
        return NOT_A_PROBABILITY;
    }
    if (prevWordsPtNodePos) {
        BinaryDictionaryBigramsIterator bigramsIt =
                getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]);
        const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
        BinaryDictionaryBigramsIterator bigramsIt(&mBigramPolicy, bigramsPosition);
        while (bigramsIt.hasNext()) {
            bigramsIt.next();
            if (bigramsIt.getBigramPos() == ptNodePos
@@ -161,7 +161,8 @@ void Ver4PatriciaTriePolicy::iterateNgramEntries(const int *const prevWordsPtNod
    if (!prevWordsPtNodePos) {
        return;
    }
    BinaryDictionaryBigramsIterator bigramsIt = getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]);
    const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
    BinaryDictionaryBigramsIterator bigramsIt(&mBigramPolicy, bigramsPosition);
    while (bigramsIt.hasNext()) {
        bigramsIt.next();
        listener->onVisitEntry(bigramsIt.getProbability(), bigramsIt.getBigramPos());
@@ -180,12 +181,6 @@ int Ver4PatriciaTriePolicy::getShortcutPositionOfPtNode(const int ptNodePos) con
            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 {
    if (ptNodePos == NOT_A_DICT_POS) {
        return NOT_A_DICT_POS;
+0 −2
Original line number Diff line number Diff line
@@ -97,8 +97,6 @@ class Ver4PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy {

    int getShortcutPositionOfPtNode(const int ptNodePos) const;

    BinaryDictionaryBigramsIterator getBigramsIteratorOfPtNode(const int ptNodePos) const;

    const DictionaryHeaderStructurePolicy *getHeaderStructurePolicy() const {
        return mHeaderPolicy;
    }
+0 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@

namespace latinime {

class DictionaryBigramsStructurePolicy;
class DictionaryShortcutsStructurePolicy;
class PtNodeArrayReader;

+4 −9
Original line number Diff line number Diff line
@@ -311,8 +311,8 @@ int PatriciaTriePolicy::getProbabilityOfPtNode(const int *const prevWordsPtNodeP
        return NOT_A_PROBABILITY;
    }
    if (prevWordsPtNodePos) {
        BinaryDictionaryBigramsIterator bigramsIt =
                getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]);
        const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
        BinaryDictionaryBigramsIterator bigramsIt(&mBigramListPolicy, bigramsPosition);
        while (bigramsIt.hasNext()) {
            bigramsIt.next();
            if (bigramsIt.getBigramPos() == ptNodePos
@@ -330,7 +330,8 @@ void PatriciaTriePolicy::iterateNgramEntries(const int *const prevWordsPtNodePos
    if (!prevWordsPtNodePos) {
        return;
    }
    BinaryDictionaryBigramsIterator bigramsIt = getBigramsIteratorOfPtNode(prevWordsPtNodePos[0]);
    const int bigramsPosition = getBigramsPositionOfPtNode(prevWordsPtNodePos[0]);
    BinaryDictionaryBigramsIterator bigramsIt(&mBigramListPolicy, bigramsPosition);
    while (bigramsIt.hasNext()) {
        bigramsIt.next();
        listener->onVisitEntry(bigramsIt.getProbability(), bigramsIt.getBigramPos());
@@ -344,12 +345,6 @@ int PatriciaTriePolicy::getShortcutPositionOfPtNode(const int ptNodePos) const {
    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 {
    if (ptNodePos == NOT_A_DICT_POS) {
        return NOT_A_DICT_POS;
Loading