summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-02-06 16:50:27 +0800
committerPeng Wu <alexepico@gmail.com>2012-02-06 16:50:27 +0800
commitfffb75f316a283dbd097b21e3a544e29ff4a3bf5 (patch)
treeb685782a2d14ccdef2ca96ce7bc68ea52afadecb
parent34909d3887a7ac3f423f00ec0913a2da6447e374 (diff)
downloadlibpinyin-fffb75f316a283dbd097b21e3a544e29ff4a3bf5.zip
libpinyin-fffb75f316a283dbd097b21e3a544e29ff4a3bf5.tar.gz
libpinyin-fffb75f316a283dbd097b21e3a544e29ff4a3bf5.tar.xz
fixes libpinyin tools
-rw-r--r--utils/storage/gen_binary_files.cpp4
-rw-r--r--utils/storage/import_interpolation.cpp24
-rw-r--r--utils/training/gen_unigram.cpp12
3 files changed, 32 insertions, 8 deletions
diff --git a/utils/storage/gen_binary_files.cpp b/utils/storage/gen_binary_files.cpp
index 4bca2cb..4519064 100644
--- a/utils/storage/gen_binary_files.cpp
+++ b/utils/storage/gen_binary_files.cpp
@@ -59,7 +59,7 @@ int main(int argc, char * argv[]){
g_free(filename);
if ( gbfile == NULL) {
- fprintf(stderr, "open gb_char.table failed!");
+ fprintf(stderr, "open gb_char.table failed!\n");
exit(ENOENT);
}
@@ -75,7 +75,7 @@ int main(int argc, char * argv[]){
g_free(filename);
if ( gbkfile == NULL) {
- fprintf(stderr, "open gbk_char.table failed!");
+ fprintf(stderr, "open gbk_char.table failed!\n");
exit(ENOENT);
}
diff --git a/utils/storage/import_interpolation.cpp b/utils/storage/import_interpolation.cpp
index 7ddb4f3..e005884 100644
--- a/utils/storage/import_interpolation.cpp
+++ b/utils/storage/import_interpolation.cpp
@@ -199,23 +199,39 @@ int main(int argc, char * argv[]){
PhraseLargeTable phrases;
MemoryChunk * chunk = new MemoryChunk;
- chunk->load("phrase_index.bin");
+ bool retval = chunk->load("phrase_index.bin");
+ if (!retval) {
+ fprintf(stderr, "open phrase_index.bin failed!\n");
+ exit(ENOENT);
+ }
phrases.load(chunk);
FacadePhraseIndex phrase_index;
//gb_char binary file
chunk = new MemoryChunk;
- chunk->load("gb_char.bin");
+ retval = chunk->load("gb_char.bin");
+ if (!retval) {
+ fprintf(stderr, "open gb_char.bin failed!\n");
+ exit(ENOENT);
+ }
phrase_index.load(1, chunk);
//gbk_char binary file
chunk = new MemoryChunk;
- chunk->load("gbk_char.bin");
+ retval = chunk->load("gbk_char.bin");
+ if (!retval) {
+ fprintf(stderr, "open gbk_char.bin failed!\n");
+ exit(ENOENT);
+ }
phrase_index.load(2, chunk);
Bigram bigram;
- bigram.attach(bigram_filename, ATTACH_CREATE|ATTACH_READWRITE);
+ retval = bigram.attach(bigram_filename, ATTACH_CREATE|ATTACH_READWRITE);
+ if (!retval) {
+ fprintf(stderr, "open %s failed!\n", bigram_filename);
+ exit(ENOENT);
+ }
taglib_init();
diff --git a/utils/training/gen_unigram.cpp b/utils/training/gen_unigram.cpp
index 022f159..cd938f6 100644
--- a/utils/training/gen_unigram.cpp
+++ b/utils/training/gen_unigram.cpp
@@ -31,12 +31,20 @@ int main(int argc, char * argv[]){
/* gb_char binary file */
MemoryChunk * chunk = new MemoryChunk;
- chunk->load("gb_char.bin");
+ bool retval = chunk->load("gb_char.bin");
+ if (!retval) {
+ fprintf(stderr, "open gb_char.bin failed!\n");
+ exit(ENOENT);
+ }
phrase_index.load(1, chunk);
/* gbk_char binary file */
chunk = new MemoryChunk;
- chunk->load("gbk_char.bin");
+ retval = chunk->load("gbk_char.bin");
+ if (!retval) {
+ fprintf(stderr, "open gbk_char.bin failed!\n");
+ exit(ENOENT);
+ }
phrase_index.load(2, chunk);
/* Note: please increase the value when corpus size becomes larger.