Home | History | Annotate | Download | only in bigram
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /*
     18  * !!!!! DO NOT CHANGE THE LOGIC IN THIS FILE !!!!!
     19  * Do not edit this file other than updating policy's interface.
     20  *
     21  * This file was generated from
     22  *   suggest/policyimpl/dictionary/structure/v4/bigram/ver4_bigram_list_policy.h
     23  */
     24 
     25 #ifndef LATINIME_BACKWARD_V402_VER4_BIGRAM_LIST_POLICY_H
     26 #define LATINIME_BACKWARD_V402_VER4_BIGRAM_LIST_POLICY_H
     27 
     28 #include "defines.h"
     29 #include "suggest/core/policy/dictionary_bigrams_structure_policy.h"
     30 #include "suggest/policyimpl/dictionary/structure/backward/v402/content/bigram_entry.h"
     31 
     32 namespace latinime {
     33 namespace backward {
     34 namespace v402 {
     35 
     36 class BigramDictContent;
     37 } // namespace v402
     38 } // namespace backward
     39 class BigramProperty;
     40 namespace backward {
     41 namespace v402 {
     42 } // namespace v402
     43 } // namespace backward
     44 class HeaderPolicy;
     45 namespace backward {
     46 namespace v402 {
     47 class TerminalPositionLookupTable;
     48 
     49 class Ver4BigramListPolicy : public DictionaryBigramsStructurePolicy {
     50  public:
     51     Ver4BigramListPolicy(BigramDictContent *const bigramDictContent,
     52             const TerminalPositionLookupTable *const terminalPositionLookupTable,
     53             const HeaderPolicy *const headerPolicy)
     54             : mBigramDictContent(bigramDictContent),
     55               mTerminalPositionLookupTable(terminalPositionLookupTable),
     56               mHeaderPolicy(headerPolicy) {}
     57 
     58     void getNextBigram(int *const outBigramPos, int *const outProbability,
     59             bool *const outHasNext, int *const bigramEntryPos) const;
     60 
     61     bool skipAllBigrams(int *const pos) const {
     62         // Do nothing because we don't need to skip bigram lists in ver4 dictionaries.
     63         return true;
     64     }
     65 
     66     bool addNewEntry(const int terminalId, const int newTargetTerminalId,
     67             const BigramProperty *const bigramProperty, bool *const outAddedNewEntry);
     68 
     69     bool removeEntry(const int terminalId, const int targetTerminalId);
     70 
     71     bool updateAllBigramEntriesAndDeleteUselessEntries(const int terminalId,
     72             int *const outBigramCount);
     73 
     74     int getBigramEntryConut(const int terminalId);
     75 
     76  private:
     77     DISALLOW_IMPLICIT_CONSTRUCTORS(Ver4BigramListPolicy);
     78 
     79     int getEntryPosToUpdate(const int targetTerminalIdToFind, const int bigramListPos,
     80             int *const outTailEntryPos) const;
     81 
     82     const BigramEntry createUpdatedBigramEntryFrom(const BigramEntry *const originalBigramEntry,
     83             const BigramProperty *const bigramProperty) const;
     84 
     85     bool updateHasNextFlag(const bool hasNext, const int bigramEntryPos);
     86 
     87     BigramDictContent *const mBigramDictContent;
     88     const TerminalPositionLookupTable *const mTerminalPositionLookupTable;
     89     const HeaderPolicy *const mHeaderPolicy;
     90 };
     91 } // namespace v402
     92 } // namespace backward
     93 } // namespace latinime
     94 #endif /* LATINIME_BACKWARD_V402_VER4_BIGRAM_LIST_POLICY_H */
     95