Nuspell
spellchecker
aff_data.hxx
Go to the documentation of this file.
1 /* Copyright 2016-2018 Dimitrij Mijoski
2  *
3  * This file is part of Nuspell.
4  *
5  * Nuspell is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Nuspell is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with Nuspell. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
24 #ifndef NUSPELL_AFF_DATA_HXX
25 #define NUSPELL_AFF_DATA_HXX
26 
27 #include "locale_utils.hxx"
28 #include "structures.hxx"
29 
30 #include <iosfwd>
31 
32 namespace nuspell {
33 
34 enum class Flag_Type {
35  SINGLE_CHAR ,
36  DOUBLE_CHAR ,
37  NUMBER ,
38  UTF8
39 };
40 
41 using Word_List_Base =
43  member<std::pair<std::string, Flag_Set>, std::string,
44  &std::pair<std::string, Flag_Set>::first>>;
54 class Word_List : public Word_List_Base {
55  public:
56  using Word_List_Base::equal_range;
57  auto equal_range(const std::wstring& word) const
58  -> std::pair<Word_List_Base::local_const_iterator,
59  Word_List_Base::local_const_iterator>;
60 };
61 
62 struct Aff_Data {
63  // data members
64  // word list
65  Word_List words;
66 
67  Substr_Replacer<wchar_t> input_substr_replacer;
68  Substr_Replacer<wchar_t> output_substr_replacer;
69  Break_Table<wchar_t> break_table;
70  std::basic_string<wchar_t> ignored_chars;
71  Prefix_Table<wchar_t> prefixes;
72  Suffix_Table<wchar_t> suffixes;
73  std::vector<Compound_Pattern<wchar_t>> compound_patterns;
74  Replacement_Table<wchar_t> replacements;
75  std::vector<Similarity_Group<wchar_t>> similarities;
76  std::basic_string<wchar_t> keyboard_closeness;
77  std::basic_string<wchar_t> try_chars;
78  Phonetic_Table<wchar_t> phonetic_table;
79 
80  // general options
81  Encoding encoding;
82  icu::Locale icu_locale;
83  Flag_Type flag_type;
84  bool complex_prefixes;
85  bool fullstrip;
86  bool checksharps;
87  bool forbid_warn;
88  char16_t circumfix_flag;
89  char16_t forbiddenword_flag;
90  char16_t keepcase_flag;
91  char16_t need_affix_flag;
92  char16_t substandard_flag;
93  char16_t warn_flag;
94 
95  std::vector<Flag_Set> flag_aliases;
96  std::string wordchars; // deprecated?
97 
98  // suggestion options
99  char16_t nosuggest_flag;
100  unsigned short max_compound_suggestions;
101  unsigned short max_ngram_suggestions;
102  unsigned short max_diff_factor;
103  bool only_max_diff;
104  bool no_split_suggestions;
105  bool suggest_with_dots;
106 
107  // compounding options
108  unsigned short compound_min_length;
109  unsigned short compound_max_word_count;
110  char16_t compound_flag;
111  char16_t compound_begin_flag;
112  char16_t compound_last_flag;
113  char16_t compound_middle_flag;
114  char16_t compound_onlyin_flag;
115  char16_t compound_permit_flag;
116  char16_t compound_forbid_flag;
117  char16_t compound_root_flag;
118  char16_t compound_force_uppercase;
119  bool compound_more_suffixes;
120  bool compound_check_duplicate;
121  bool compound_check_rep;
122  bool compound_check_case;
123  bool compound_check_triple;
124  bool compound_simplified_triple;
125 
126  Compound_Rule_Table compound_rules;
127 
128  unsigned short compound_syllable_max;
129  std::string compound_syllable_vowels;
130  Flag_Set compound_syllable_num;
131 
132  // methods
133  auto parse_aff(std::istream& in) -> bool;
134  auto parse_dic(std::istream& in) -> bool;
135  auto parse_aff_dic(std::istream& aff, std::istream& dic)
136  {
137  if (parse_aff(aff))
138  return parse_dic(dic);
139  return false;
140  }
141 };
142 } // namespace nuspell
143 
144 #endif // NUSPELL_AFF_DATA_HXX
Definition: locale_utils.hxx:91
Definition: structures.hxx:1042
Definition: structures.hxx:521
Data structures, private header.
Encoding transformations, private header.
UTF-8 flag, e.g.
Library main namespace.
Definition: aff_data.cxx:78
numerical flag, e.g.
A Set class backed by a string.
Definition: structures.hxx:50
Definition: aff_data.hxx:62
single-character flag, e.g.
double-character flag, e.g for "aa"
Map between words and word_flags.
Definition: aff_data.hxx:54
Flag_Type
Definition: aff_data.hxx:34
Definition: structures.hxx:944