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" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 size_t word_tab_offset = utf8word.find('\t'); | 112 size_t word_tab_offset = utf8word.find('\t'); |
113 if (word_tab_offset != std::string::npos) | 113 if (word_tab_offset != std::string::npos) |
114 utf8word = utf8word.substr(0, word_tab_offset); | 114 utf8word = utf8word.substr(0, word_tab_offset); |
115 | 115 |
116 WordSet::iterator found = word_set->find(utf8word); | 116 WordSet::iterator found = word_set->find(utf8word); |
117 std::set<int> affix_vector; | 117 std::set<int> affix_vector; |
118 affix_vector.insert(affix_index); | 118 affix_vector.insert(affix_index); |
119 | 119 |
120 if (found == word_set->end()) { | 120 if (found == word_set->end()) { |
121 word_set->insert(std::make_pair(utf8word, affix_vector)); | 121 word_set->insert(std::make_pair(utf8word, affix_vector)); |
122 } else if (affix_index == 0) { | |
123 // If we have no affix, add the no-affix case to the affix-vector. | |
124 found->second.insert(affix_index); | |
rpetterson
2012/12/15 03:53:47
I'm not sure I see how this fixes the issue where
please use gerrit instead
2012/12/15 04:19:14
This fixes the following case:
Word/S
please use gerrit instead
2012/12/15 22:00:19
Rlp: Let me investigate more into how convert_dict
| |
122 } else { | 125 } else { |
123 // The affixes of the delta file should override those in the | 126 // The later added affixes should override the earlier added affixes. This |
124 // dictionary file. | 127 // is useful for overrding the affixes in dic file from dic_delta file, |
128 // for example. | |
125 found->second.swap(affix_vector); | 129 found->second.swap(affix_vector); |
126 } | 130 } |
127 } | 131 } |
128 | 132 |
129 return true; | 133 return true; |
130 } | 134 } |
131 | 135 |
132 } // namespace | 136 } // namespace |
133 | 137 |
134 DicReader::DicReader(const FilePath& path) { | 138 DicReader::DicReader(const FilePath& path) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 std::sort(affixes.begin(), affixes.end()); | 188 std::sort(affixes.begin(), affixes.end()); |
185 words_.push_back(std::make_pair(word->first, affixes)); | 189 words_.push_back(std::make_pair(word->first, affixes)); |
186 } | 190 } |
187 | 191 |
188 // Double-check that the words are sorted. | 192 // Double-check that the words are sorted. |
189 std::sort(words_.begin(), words_.end()); | 193 std::sort(words_.begin(), words_.end()); |
190 return true; | 194 return true; |
191 } | 195 } |
192 | 196 |
193 } // namespace convert_dict | 197 } // namespace convert_dict |
OLD | NEW |