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.
5 #ifndef CHROME_THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_WRITER_H__
6 #define CHROME_THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_WRITER_H__
11 #include "base/basictypes.h"
17 // Class for creating a binary dictionary file from data read from Hunspell
18 // spellchecker files.
21 typedef std::vector
< std::pair
<std::string
, std::vector
<int> > > WordList
;
27 void SetComment(const std::string
& comment
) {
30 void SetAffixRules(const std::vector
<std::string
>& rules
) {
33 void SetAffixGroups(const std::vector
<std::string
>& groups
) {
34 affix_groups_
= groups
;
37 const std::vector
< std::pair
<std::string
, std::string
> >& replacements
) {
38 replacements_
= replacements
;
40 void SetOtherCommands(const std::vector
<std::string
>& commands
) {
41 other_commands_
= commands
;
44 // The words must be sorted already.
45 void SetWords(const WordList
& words
);
47 // Returns the serialized data for the entire file. You must call all the
48 // setters above before this.
49 std::string
GetBDict() const;
52 // Converts the affix members to a string.
53 void SerializeAff(std::string
* output
) const;
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_
;
62 // Root of the generated trie. Filled by SetWords.
65 DISALLOW_EVIL_CONSTRUCTORS(BDictWriter
);
68 } // namespace hunspell
70 #endif // CHROME_THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_WRITER_H__