OLD | NEW |
1 /** | 1 /** |
2 *******************************************************************************
***** | 2 *******************************************************************************
***** |
3 * Copyright (C) 2006-2009, International Business Machines Corporation and othe
rs. * | 3 * Copyright (C) 2006-2009, International Business Machines Corporation and othe
rs. * |
4 * All Rights Reserved.
* | 4 * All Rights Reserved.
* |
5 *******************************************************************************
***** | 5 *******************************************************************************
***** |
6 */ | 6 */ |
7 | 7 |
8 #include "unicode/utypes.h" | 8 #include "unicode/utypes.h" |
9 | 9 |
10 #if !UCONFIG_NO_BREAK_ITERATION | 10 #if !UCONFIG_NO_BREAK_ITERATION |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 UErrorCode status = U_ZERO_ERROR; | 219 UErrorCode status = U_ZERO_ERROR; |
220 UScriptCode code = uscript_getScript(c, &status); | 220 UScriptCode code = uscript_getScript(c, &status); |
221 if (U_SUCCESS(status)) { | 221 if (U_SUCCESS(status)) { |
222 const CompactTrieDictionary *dict = loadDictionaryFor(code, breakType); | 222 const CompactTrieDictionary *dict = loadDictionaryFor(code, breakType); |
223 if (dict != NULL) { | 223 if (dict != NULL) { |
224 const LanguageBreakEngine *engine = NULL; | 224 const LanguageBreakEngine *engine = NULL; |
225 switch(code) { | 225 switch(code) { |
226 case USCRIPT_THAI: | 226 case USCRIPT_THAI: |
227 engine = new ThaiBreakEngine(dict, status); | 227 engine = new ThaiBreakEngine(dict, status); |
228 break; | 228 break; |
| 229 |
| 230 case USCRIPT_HANGUL: |
| 231 engine = new CjkBreakEngine(dict, kKorean, status); |
| 232 break; |
| 233 |
| 234 // use same BreakEngine and dictionary for both Chinese and Japanese |
| 235 case USCRIPT_HIRAGANA: |
| 236 case USCRIPT_KATAKANA: |
| 237 case USCRIPT_HAN: |
| 238 engine = new CjkBreakEngine(dict, kChineseJapanese, status); |
| 239 break; |
| 240 #if 0 |
| 241 // TODO: Have to get some characters with script=common handled |
| 242 // by CjkBreakEngine (e.g. U+309B). Simply subjecting |
| 243 // them to CjkBreakEngine does not work. The engine has to |
| 244 // special-case them. |
| 245 case USCRIPT_COMMON: |
| 246 { |
| 247 UBlockCode block = ublock_getCode(code); |
| 248 if (block == UBLOCK_HIRAGANA || block == UBLOCK_KATAKANA) |
| 249 engine = new CjkBreakEngine(dict, kChineseJapanese, status); |
| 250 break; |
| 251 } |
| 252 #endif |
229 default: | 253 default: |
230 break; | 254 break; |
231 } | 255 } |
232 if (engine == NULL) { | 256 if (engine == NULL) { |
233 delete dict; | 257 delete dict; |
234 } | 258 } |
235 else if (U_FAILURE(status)) { | 259 else if (U_FAILURE(status)) { |
236 delete engine; | 260 delete engine; |
237 engine = NULL; | 261 engine = NULL; |
238 } | 262 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 const CompactTrieDictionary *dict = new CompactTrieDictionary( | 298 const CompactTrieDictionary *dict = new CompactTrieDictionary( |
275 file, status); | 299 file, status); |
276 if (U_SUCCESS(status) && dict == NULL) { | 300 if (U_SUCCESS(status) && dict == NULL) { |
277 status = U_MEMORY_ALLOCATION_ERROR; | 301 status = U_MEMORY_ALLOCATION_ERROR; |
278 } | 302 } |
279 if (U_FAILURE(status)) { | 303 if (U_FAILURE(status)) { |
280 delete dict; | 304 delete dict; |
281 dict = NULL; | 305 dict = NULL; |
282 } | 306 } |
283 return dict; | 307 return dict; |
| 308 } else if (dictfname != NULL){ |
| 309 //create dummy dict if dictionary filename not valid |
| 310 UChar c = 0x0020; |
| 311 status = U_ZERO_ERROR; |
| 312 MutableTrieDictionary *mtd = new MutableTrieDictionary(c, status, TRUE); |
| 313 mtd->addWord(&c, 1, status, 1); |
| 314 return new CompactTrieDictionary(*mtd, status); |
284 } | 315 } |
285 return NULL; | 316 return NULL; |
286 } | 317 } |
287 | 318 |
288 U_NAMESPACE_END | 319 U_NAMESPACE_END |
289 | 320 |
290 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ | 321 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ |
OLD | NEW |