OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <algorithm> | 5 #include <algorithm> |
6 #include <deque> | 6 #include <deque> |
7 #include <fstream> | 7 #include <fstream> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 void DictionaryService::CreatDictFromEmbeddedDataIfNotExist( | 37 void DictionaryService::CreatDictFromEmbeddedDataIfNotExist( |
38 const std::string path) { | 38 const std::string path) { |
39 if (std::ifstream(path.c_str())) | 39 if (std::ifstream(path.c_str())) |
40 return; | 40 return; |
41 std::ofstream dic_file(path.c_str(), | 41 std::ofstream dic_file(path.c_str(), |
42 std::ofstream::out | std::ofstream::binary); | 42 std::ofstream::out | std::ofstream::binary); |
43 dic_file.write(prediction::kDictFile.data, prediction::kDictFile.size); | 43 dic_file.write(prediction::kDictFile.data, prediction::kDictFile.size); |
44 dic_file.close(); | 44 dic_file.close(); |
45 } | 45 } |
46 | 46 |
47 latinime::Dictionary* const DictionaryService::OpenDictionary( | 47 latinime::Dictionary* DictionaryService::OpenDictionary( |
48 const std::string path, | 48 const std::string path, |
49 const int start_offset, | 49 const int start_offset, |
50 const int size, | 50 const int size, |
51 const bool is_updatable) { | 51 const bool is_updatable) { |
52 latinime::DictionaryStructureWithBufferPolicy::StructurePolicyPtr | 52 latinime::DictionaryStructureWithBufferPolicy::StructurePolicyPtr |
53 dictionary_structure_with_buffer_policy( | 53 dictionary_structure_with_buffer_policy( |
54 latinime::DictionaryStructureWithBufferPolicyFactory:: | 54 latinime::DictionaryStructureWithBufferPolicyFactory:: |
55 newPolicyForExistingDictFile(path.c_str(), start_offset, size, | 55 newPolicyForExistingDictFile(path.c_str(), start_offset, size, |
56 is_updatable)); | 56 is_updatable)); |
57 if (!dictionary_structure_with_buffer_policy) { | 57 if (!dictionary_structure_with_buffer_policy) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 prev_word_codepoint_count[i] = prev_word_size; | 191 prev_word_codepoint_count[i] = prev_word_size; |
192 are_beginning_of_sentence[i] = prev_words[i]->is_beginning_of_sentence; | 192 are_beginning_of_sentence[i] = prev_words[i]->is_beginning_of_sentence; |
193 } | 193 } |
194 latinime::PrevWordsInfo prev_words_info = | 194 latinime::PrevWordsInfo prev_words_info = |
195 latinime::PrevWordsInfo(prev_word_codepoints, prev_word_codepoint_count, | 195 latinime::PrevWordsInfo(prev_word_codepoints, prev_word_codepoint_count, |
196 are_beginning_of_sentence, prevwords_count); | 196 are_beginning_of_sentence, prevwords_count); |
197 return prev_words_info; | 197 return prev_words_info; |
198 } | 198 } |
199 | 199 |
200 } // namespace prediction | 200 } // namespace prediction |
OLD | NEW |