| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_WRITER_H__ | |
| 6 #define CHROME_THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_WRITER_H__ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 | |
| 13 namespace hunspell { | |
| 14 | |
| 15 class DicNode; | |
| 16 | |
| 17 // Class for creating a binary dictionary file from data read from Hunspell | |
| 18 // spellchecker files. | |
| 19 class BDictWriter { | |
| 20 public: | |
| 21 typedef std::vector< std::pair<std::string, std::vector<int> > > WordList; | |
| 22 | |
| 23 BDictWriter(); | |
| 24 ~BDictWriter(); | |
| 25 | |
| 26 // Affix setters. | |
| 27 void SetComment(const std::string& comment) { | |
| 28 comment_ = comment; | |
| 29 } | |
| 30 void SetAffixRules(const std::vector<std::string>& rules) { | |
| 31 affix_rules_ = rules; | |
| 32 } | |
| 33 void SetAffixGroups(const std::vector<std::string>& groups) { | |
| 34 affix_groups_ = groups; | |
| 35 } | |
| 36 void SetReplacements( | |
| 37 const std::vector< std::pair<std::string, std::string> >& replacements) { | |
| 38 replacements_ = replacements; | |
| 39 } | |
| 40 void SetOtherCommands(const std::vector<std::string>& commands) { | |
| 41 other_commands_ = commands; | |
| 42 } | |
| 43 | |
| 44 // The words must be sorted already. | |
| 45 void SetWords(const WordList& words); | |
| 46 | |
| 47 // Returns the serialized data for the entire file. You must call all the | |
| 48 // setters above before this. | |
| 49 std::string GetBDict() const; | |
| 50 | |
| 51 private: | |
| 52 // Converts the affix members to a string. | |
| 53 void SerializeAff(std::string* output) const; | |
| 54 | |
| 55 // Affix members. | |
| 56 std::string comment_; | |
| 57 std::vector<std::string> affix_rules_; | |
| 58 std::vector<std::string> affix_groups_; | |
| 59 std::vector< std::pair<std::string, std::string> > replacements_; | |
| 60 std::vector<std::string> other_commands_; | |
| 61 | |
| 62 // Root of the generated trie. Filled by SetWords. | |
| 63 DicNode* trie_root_; | |
| 64 | |
| 65 DISALLOW_EVIL_CONSTRUCTORS(BDictWriter); | |
| 66 }; | |
| 67 | |
| 68 } // namespace hunspell | |
| 69 | |
| 70 #endif // CHROME_THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_WRITER_H__ | |
| OLD | NEW |