summaryrefslogtreecommitdiffstats
path: root/utils/training/gen_ngram.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-04-28 15:04:46 +0800
committerPeng Wu <alexepico@gmail.com>2011-04-28 15:04:46 +0800
commit80d2b005249b772e7cd7fdf763e217576d401823 (patch)
tree1b1611cef942e5b98b88c1448ad53d9df7ba5e85 /utils/training/gen_ngram.cpp
parentb7909ecd1b39843c99b44118a8e0fe269da7f098 (diff)
downloadlibpinyin-80d2b005249b772e7cd7fdf763e217576d401823.tar.gz
libpinyin-80d2b005249b772e7cd7fdf763e217576d401823.tar.xz
libpinyin-80d2b005249b772e7cd7fdf763e217576d401823.zip
use errno
Diffstat (limited to 'utils/training/gen_ngram.cpp')
-rw-r--r--utils/training/gen_ngram.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/utils/training/gen_ngram.cpp b/utils/training/gen_ngram.cpp
index 367728a..4ac75e3 100644
--- a/utils/training/gen_ngram.cpp
+++ b/utils/training/gen_ngram.cpp
@@ -31,7 +31,6 @@ static PhraseLargeTable * g_phrases = NULL;
void print_help(){
printf("gen_ngram [--skip-pi-gram-training] [--skip-unigram-training]\n");
printf(" [--bigram-file <FILENAME>]\n");
- exit(1);
}
int main(int argc, char * argv[]){
@@ -44,16 +43,20 @@ int main(int argc, char * argv[]){
while ( i < argc ){
if ( strcmp("--help", argv[i] ) == 0){
print_help();
+ exit(0);
}else if ( strcmp("--skip-pi-gram-training", argv[i] ) == 0) {
train_pi_gram = false;
}else if ( strcmp("--skip-unigram-training", argv[i] ) == 0) {
train_unigram = false;
}else if ( strcmp("--bigram-file", argv[i] ) == 0){
- if ( ++i >= argc )
+ if ( ++i >= argc ) {
print_help();
+ exit(EINVAL);
+ }
bigram_filename = argv[i];
}else{
print_help();
+ exit(EINVAL);
}
++i;
}
@@ -63,14 +66,14 @@ int main(int argc, char * argv[]){
FILE * gb_file = fopen("../../data/gb_char.table", "r");
if ( gb_file == NULL ){
fprintf(stderr, "can't open gb_char.table!\n");
- exit(1);
+ exit(ENOENT);
}
g_phrases->load_text(gb_file);
fclose(gb_file);
FILE * gbk_file = fopen("../../data/gbk_char.table", "r");
if ( gbk_file == NULL ){
fprintf(stderr, "can't open gbk_char.table!\n");
- exit(1);
+ exit(ENOENT);
}
g_phrases->load_text(gbk_file);
fclose(gbk_file);