diff options
author | Peng Wu <alexepico@gmail.com> | 2013-04-10 15:45:05 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2013-04-10 15:45:05 +0800 |
commit | 274f51f5af2555c4aa2b95f5c45e1468be572f18 (patch) | |
tree | 95c817d79d4f5799682e3760545b424348dbde94 | |
parent | 5cebe47fae1d07adc1d099c2fdbc1b06a4d526ce (diff) | |
download | libpinyin-274f51f5af2555c4aa2b95f5c45e1468be572f18.tar.gz libpinyin-274f51f5af2555c4aa2b95f5c45e1468be572f18.tar.xz libpinyin-274f51f5af2555c4aa2b95f5c45e1468be572f18.zip |
fixes make distcheck
-rw-r--r-- | data/Makefile.am | 4 | ||||
-rw-r--r-- | utils/storage/import_interpolation.cpp | 27 | ||||
-rw-r--r-- | utils/training/gen_unigram.cpp | 24 |
3 files changed, 51 insertions, 4 deletions
diff --git a/data/Makefile.am b/data/Makefile.am index da34394..fe1a6de 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -57,8 +57,8 @@ $(tablefiles): interpolation2.text bigram.db: $(textual_model_data) $(RM) $(binary_model_data) ../utils/storage/gen_binary_files --table-dir $(top_srcdir)/data - ../utils/storage/import_interpolation < $(top_srcdir)/data/interpolation2.text - ../utils/training/gen_unigram + ../utils/storage/import_interpolation --table-dir $(top_srcdir)/data < $(top_srcdir)/data/interpolation2.text + ../utils/training/gen_unigram --table-dir $(top_srcdir)/data phrase_index.bin pinyin_index.bin $(binfiles): bigram.db diff --git a/utils/storage/import_interpolation.cpp b/utils/storage/import_interpolation.cpp index c1ac601..5a0030e 100644 --- a/utils/storage/import_interpolation.cpp +++ b/utils/storage/import_interpolation.cpp @@ -20,10 +20,21 @@ */ #include <stdio.h> +#include <locale.h> #include <glib.h> #include "pinyin_internal.h" #include "utils_helper.h" + +static const gchar * table_dir = "."; + +static GOptionEntry entries[] = +{ + {"table-dir", 0, 0, G_OPTION_ARG_FILENAME, &table_dir, "table directory", NULL}, + {NULL} +}; + + enum LINE_TYPE{ BEGIN_LINE = 1, END_LINE, @@ -224,13 +235,27 @@ int main(int argc, char * argv[]){ FILE * input = stdin; const char * bigram_filename = "bigram.db"; + setlocale(LC_ALL, ""); + + GError * error = NULL; + GOptionContext * context; + + context = g_option_context_new("- import interpolation model"); + g_option_context_add_main_entries(context, entries, NULL); + if (!g_option_context_parse(context, &argc, &argv, &error)) { + g_print("option parsing failed:%s\n", error->message); + exit(EINVAL); + } + SystemTableInfo system_table_info; - bool retval = system_table_info.load("table.conf"); + gchar * filename = g_build_filename(table_dir, "table.conf", NULL); + bool retval = system_table_info.load(filename); if (!retval) { fprintf(stderr, "load table.conf failed.\n"); exit(ENOENT); } + g_free(filename); PhraseLargeTable2 phrase_table; diff --git a/utils/training/gen_unigram.cpp b/utils/training/gen_unigram.cpp index 47aee91..83a15c8 100644 --- a/utils/training/gen_unigram.cpp +++ b/utils/training/gen_unigram.cpp @@ -20,20 +20,42 @@ */ #include <stdio.h> +#include <locale.h> #include "pinyin_internal.h" #include "utils_helper.h" +static const gchar * table_dir = "."; + +static GOptionEntry entries[] = +{ + {"table-dir", 0, 0, G_OPTION_ARG_FILENAME, &table_dir, "table directory", NULL}, + {NULL} +}; + /* increase all unigram frequency by a constant. */ int main(int argc, char * argv[]){ + setlocale(LC_ALL, ""); + + GError * error = NULL; + GOptionContext * context; + + context = g_option_context_new("- increase uni-gram"); + g_option_context_add_main_entries(context, entries, NULL); + if (!g_option_context_parse(context, &argc, &argv, &error)) { + g_print("option parsing failed:%s\n", error->message); + exit(EINVAL); + } SystemTableInfo system_table_info; - bool retval = system_table_info.load("table.conf"); + gchar * filename = g_build_filename(table_dir, "table.conf", NULL); + bool retval = system_table_info.load(filename); if (!retval) { fprintf(stderr, "load table.conf failed.\n"); exit(ENOENT); } + g_free(filename); FacadePhraseIndex phrase_index; |