OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/tools/convert_dict/dic_reader.h" | 5 #include "chrome/tools/convert_dict/dic_reader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/tools/convert_dict/aff_reader.h" | 12 #include "chrome/tools/convert_dict/aff_reader.h" |
13 #include "chrome/tools/convert_dict/hunspell_reader.h" | 13 #include "chrome/tools/convert_dict/hunspell_reader.h" |
14 | 14 |
15 namespace convert_dict { | 15 namespace convert_dict { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Maps each unique word to the unique affix group IDs associated with it. | 19 // Maps each unique word to the unique affix group IDs associated with it. |
20 typedef std::map<std::string, std::set<int> > WordSet; | 20 typedef std::map<std::string, std::set<int> > WordSet; |
21 | 21 |
22 void SplitDicLine(const std::string& line, std::vector<std::string>* output) { | 22 void SplitDicLine(const std::string& line, std::vector<std::string>* output) { |
23 // We split the line on a slash not preceeded by a backslash. A slash at the | 23 // We split the line on a slash not preceded by a backslash. A slash at the |
24 // beginning of the line is not a separator either. | 24 // beginning of the line is not a separator either. |
25 size_t slash_index = line.size(); | 25 size_t slash_index = line.size(); |
26 for (size_t i = 0; i < line.size(); i++) { | 26 for (size_t i = 0; i < line.size(); i++) { |
27 if (line[i] == '/' && i > 0 && line[i - 1] != '\\') { | 27 if (line[i] == '/' && i > 0 && line[i - 1] != '\\') { |
28 slash_index = i; | 28 slash_index = i; |
29 break; | 29 break; |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 output->clear(); | 33 output->clear(); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 std::reverse(affixes.begin(), affixes.end()); | 181 std::reverse(affixes.begin(), affixes.end()); |
182 words_.push_back(std::make_pair(word->first, affixes)); | 182 words_.push_back(std::make_pair(word->first, affixes)); |
183 } | 183 } |
184 | 184 |
185 // Double-check that the words are sorted. | 185 // Double-check that the words are sorted. |
186 std::sort(words_.begin(), words_.end()); | 186 std::sort(words_.begin(), words_.end()); |
187 return true; | 187 return true; |
188 } | 188 } |
189 | 189 |
190 } // namespace convert_dict | 190 } // namespace convert_dict |
OLD | NEW |