1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <assert.h> 18 #include <stdlib.h> 19 #include <stdio.h> 20 #include <time.h> 21 #include <unistd.h> 22 #include "../include/dicttrie.h" 23 24 using namespace ime_pinyin; 25 26 /** 27 * Build binary dictionary model. Make sure that ___BUILD_MODEL___ is defined 28 * in dictdef.h. 29 */ 30 int main(int argc, char* argv[]) { 31 DictTrie* dict_trie = new DictTrie(); 32 bool success; 33 if (argc >= 3) 34 success = dict_trie->build_dict(argv[1], argv[2]); 35 else 36 success = dict_trie->build_dict("../data/rawdict_utf16_65105_freq.txt", 37 "../data/valid_utf16.txt"); 38 39 if (success) { 40 printf("Build dictionary successfully.\n"); 41 } else { 42 printf("Build dictionary unsuccessfully.\n"); 43 return -1; 44 } 45 46 success = dict_trie->save_dict("../../res/raw/dict_pinyin.dat"); 47 48 if (success) { 49 printf("Save dictionary successfully.\n"); 50 } else { 51 printf("Save dictionary unsuccessfully.\n"); 52 return -1; 53 } 54 55 return 0; 56 } 57