17898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project/* 27898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * Copyright (C) 2009 The Android Open Source Project 37898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * 47898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 57898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * you may not use this file except in compliance with the License. 67898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * You may obtain a copy of the License at 77898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * 87898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 97898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * 107898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software 117898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 127898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * See the License for the specific language governing permissions and 147898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project * limitations under the License. 157898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project */ 167898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 177898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#ifndef PINYINIME_INCLUDE_DICTTRIE_H__ 187898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#define PINYINIME_INCLUDE_DICTTRIE_H__ 197898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 207898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#include <stdlib.h> 217898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#include "./atomdictbase.h" 227898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#include "./dictdef.h" 237898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#include "./dictlist.h" 247898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#include "./searchutility.h" 257898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 267898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Projectnamespace ime_pinyin { 277898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 287898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Projectclass DictTrie : AtomDictBase { 297898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project private: 307898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project typedef struct ParsingMark { 317898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t node_offset:24; 327898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t node_num:8; // Number of nodes with this spelling id given 337898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // by spl_id. If spl_id is a Shengmu, for nodes 347898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // in the first layer of DictTrie, it equals to 357898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // SpellingTrie::shm2full_num(); but for those 367898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // nodes which are not in the first layer, 377898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // node_num < SpellingTrie::shm2full_num(). 387898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // For a full spelling id, node_num = 1; 397898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project }; 407898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 417898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Used to indicate an extended mile stone. 427898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // An extended mile stone is used to mark a partial match in the dictionary 437898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // trie to speed up further potential extending. 447898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // For example, when the user inputs "w", a mile stone is created to mark the 457898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // partial match status, so that when user inputs another char 'm', it will be 467898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // faster to extend search space based on this mile stone. 477898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // 487898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // For partial match status of "wm", there can be more than one sub mile 497898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // stone, for example, "wm" can be matched to "wanm", "wom", ..., etc, so 507898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // there may be more one parsing mark used to mark these partial matchings. 517898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // A mile stone records the starting position in the mark list and number of 527898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // marks. 537898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project struct MileStone { 547898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 mark_start; 557898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 mark_num; 567898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project }; 577898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 587898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project DictList* dict_list_; 597898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 607898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project const SpellingTrie *spl_trie_; 617898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 627898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LmaNodeLE0* root_; // Nodes for root and the first layer. 637898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LmaNodeGE1* nodes_ge1_; // Nodes for other layers. 647898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 657898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // An quick index from spelling id to the LmaNodeLE0 node buffer, or 667898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // to the root_ buffer. 677898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Index length: 687898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // SpellingTrie::get_instance().get_spelling_num() + 1. The last one is used 697898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // to get the end. 707898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // All Shengmu ids are not indexed because they will be converted into 717898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // corresponding full ids. 727898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // So, given an id splid, the son is: 737898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // root_[splid_le0_index_[splid - kFullSplIdStart]] 747898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 *splid_le0_index_; 757898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 767898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t lma_node_num_le0_; 777898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t lma_node_num_ge1_; 787898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 797898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // The first part is for homophnies, and the last top_lma_num_ items are 807898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // lemmas with highest scores. 817898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project unsigned char *lma_idx_buf_; 827898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t lma_idx_buf_len_; // The total size of lma_idx_buf_ in byte. 837898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t total_lma_num_; // Total number of lemmas in this dictionary. 847898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t top_lmas_num_; // Number of lemma with highest scores. 857898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 867898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Parsing mark list used to mark the detailed extended statuses. 877898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project ParsingMark *parsing_marks_; 887898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // The position for next available mark. 897898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 parsing_marks_pos_; 907898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 917898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Mile stone list used to mark the extended status. 927898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project MileStone *mile_stones_; 937898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // The position for the next available mile stone. We use positions (except 0) 947898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // as handles. 957898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project MileStoneHandle mile_stones_pos_; 967898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 977898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Get the offset of sons for a node. 987898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project inline size_t get_son_offset(const LmaNodeGE1 *node); 997898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1007898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Get the offset of homonious ids for a node. 1017898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project inline size_t get_homo_idx_buf_offset(const LmaNodeGE1 *node); 1027898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1037898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Get the lemma id by the offset. 1047898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project inline LemmaIdType get_lemma_id(size_t id_offset); 1057898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1067898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project void free_resource(bool free_dict_list); 1077898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1087898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool load_dict(FILE *fp); 1097898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1107898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Given a LmaNodeLE0 node, extract the lemmas specified by it, and fill 1117898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // them into the lpi_items buffer. 1127898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // This function is called by the search engine. 1137898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t fill_lpi_buffer(LmaPsbItem lpi_items[], size_t max_size, 1147898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LmaNodeLE0 *node); 1157898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1167898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Given a LmaNodeGE1 node, extract the lemmas specified by it, and fill 1177898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // them into the lpi_items buffer. 1187898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // This function is called by inner functions extend_dict0(), extend_dict1() 1197898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // and extend_dict2(). 1207898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t fill_lpi_buffer(LmaPsbItem lpi_items[], size_t max_size, 1217898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t homo_buf_off, LmaNodeGE1 *node, 1227898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 lma_len); 1237898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1247898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Extend in the trie from level 0. 1257898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project MileStoneHandle extend_dict0(MileStoneHandle from_handle, 1267898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project const DictExtPara *dep, LmaPsbItem *lpi_items, 1277898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t lpi_max, size_t *lpi_num); 1287898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1297898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Extend in the trie from level 1. 1307898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project MileStoneHandle extend_dict1(MileStoneHandle from_handle, 1317898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project const DictExtPara *dep, LmaPsbItem *lpi_items, 1327898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t lpi_max, size_t *lpi_num); 1337898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1347898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Extend in the trie from level 2. 1357898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project MileStoneHandle extend_dict2(MileStoneHandle from_handle, 1367898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project const DictExtPara *dep, LmaPsbItem *lpi_items, 1377898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t lpi_max, size_t *lpi_num); 1387898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1397898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Try to extend the given spelling id buffer, and if the given id_lemma can 1407898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // be successfully gotten, return true; 1417898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // The given spelling ids are all valid full ids. 1427898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool try_extend(const uint16 *splids, uint16 splid_num, LemmaIdType id_lemma); 1437898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1447898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#ifdef ___BUILD_MODEL___ 1457898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool save_dict(FILE *fp); 1467898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#endif // ___BUILD_MODEL___ 1477898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1487898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project static const int kMaxMileStone = 100; 1497898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project static const int kMaxParsingMark = 600; 1507898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project static const MileStoneHandle kFirstValidMileStoneHandle = 1; 1517898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1527898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project friend class DictParser; 1537898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project friend class DictBuilder; 1547898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1557898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project public: 1567898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1577898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project DictTrie(); 1587898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project ~DictTrie(); 1597898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1607898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#ifdef ___BUILD_MODEL___ 1617898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Construct the tree from the file fn_raw. 1627898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // fn_validhzs provide the valid hanzi list. If fn_validhzs is 1637898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // NULL, only chars in GB2312 will be included. 1647898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool build_dict(const char *fn_raw, const char *fn_validhzs); 1657898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1667898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Save the binary dictionary 1677898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Actually, the SpellingTrie/DictList instance will be also saved. 1687898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool save_dict(const char *filename); 1697898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#endif // ___BUILD_MODEL___ 1707898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1717898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project void convert_to_hanzis(char16 *str, uint16 str_len); 1727898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1737898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project void convert_to_scis_ids(char16 *str, uint16 str_len); 1747898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1757898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Load a binary dictionary 1767898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // The SpellingTrie instance/DictList will be also loaded 1777898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool load_dict(const char *filename, LemmaIdType start_id, 1787898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LemmaIdType end_id); 1797898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool load_dict_fd(int sys_fd, long start_offset, long length, 1807898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LemmaIdType start_id, LemmaIdType end_id); 1817898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool close_dict() {return true;} 1827898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t number_of_lemmas() {return 0;} 1837898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1847898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project void reset_milestones(uint16 from_step, MileStoneHandle from_handle); 1857898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1867898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project MileStoneHandle extend_dict(MileStoneHandle from_handle, 1877898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project const DictExtPara *dep, 1887898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LmaPsbItem *lpi_items, 1897898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t lpi_max, size_t *lpi_num); 1907898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1917898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t get_lpis(const uint16 *splid_str, uint16 splid_str_len, 1927898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LmaPsbItem *lpi_items, size_t lpi_max); 1937898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1947898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 get_lemma_str(LemmaIdType id_lemma, char16 *str_buf, uint16 str_max); 1957898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1967898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 get_lemma_splids(LemmaIdType id_lemma, uint16 *splids, 1977898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 splids_max, bool arg_valid); 1987898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 1997898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t predict(const char16 *last_hzs, uint16 hzs_len, 2007898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project NPredictItem *npre_items, size_t npre_max, 2017898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t b4_used); 2027898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2037898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LemmaIdType put_lemma(char16 lemma_str[], uint16 splids[], 2047898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 lemma_len, uint16 count) {return 0;} 2057898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2067898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LemmaIdType update_lemma(LemmaIdType lemma_id, int16 delta_count, 2077898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool selected) {return 0;} 2087898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2097898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LemmaIdType get_lemma_id(char16 lemma_str[], uint16 splids[], 2107898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 lemma_len) {return 0;} 2117898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2127898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LmaScoreType get_lemma_score(LemmaIdType lemma_id) {return 0;} 2137898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2147898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LmaScoreType get_lemma_score(char16 lemma_str[], uint16 splids[], 2157898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project uint16 lemma_len) {return 0;} 2167898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2177898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project bool remove_lemma(LemmaIdType lemma_id) {return false;} 2187898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2197898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t get_total_lemma_count() {return 0;} 2207898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project void set_total_lemma_count_of_others(size_t count); 2217898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2227898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project void flush_cache() {} 2237898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2247898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project LemmaIdType get_lemma_id(const char16 lemma_str[], uint16 lemma_len); 2257898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2267898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // Fill the lemmas with highest scores to the prediction buffer. 2277898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project // his_len is the history length to fill in the prediction buffer. 2287898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t predict_top_lmas(size_t his_len, NPredictItem *npre_items, 2297898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project size_t npre_max, size_t b4_used); 2307898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project}; 2317898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project} 2327898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project 2337898d76cc005bbe1c5893a9f57439561e0771ccThe Android Open Source Project#endif // PINYINIME_INCLUDE_DICTTRIE_H__ 234