diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/storage/gen_binary_files.cpp | 7 | ||||
-rw-r--r-- | utils/training/gen_unigram.cpp | 7 | ||||
-rw-r--r-- | utils/utils_helper.h | 14 |
3 files changed, 20 insertions, 8 deletions
diff --git a/utils/storage/gen_binary_files.cpp b/utils/storage/gen_binary_files.cpp index 1ec6fe3..725c3f2 100644 --- a/utils/storage/gen_binary_files.cpp +++ b/utils/storage/gen_binary_files.cpp @@ -55,10 +55,13 @@ int main(int argc, char * argv[]){ /* generate phrase index */ FacadePhraseIndex phrase_index; for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { - const char * tablename = pinyin_table_files[i]; - if (NULL == tablename) + const pinyin_table_info_t * table_info = pinyin_phrase_files + i; + + if (SYSTEM_FILE != table_info->m_file_type) continue; + const char * tablename = table_info->m_table_filename; + gchar * filename = g_build_filename(table_dir, tablename, NULL); FILE * tablefile = fopen(filename, "r"); diff --git a/utils/training/gen_unigram.cpp b/utils/training/gen_unigram.cpp index 72bb2a8..52295a7 100644 --- a/utils/training/gen_unigram.cpp +++ b/utils/training/gen_unigram.cpp @@ -36,10 +36,13 @@ int main(int argc, char * argv[]){ * To avoid zero value when computing unigram frequency in float format. */ for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { - const char * binfile = pinyin_phrase_files[i]; - if (NULL == binfile) + const pinyin_table_info_t * table_info = pinyin_phrase_files + i; + + if (SYSTEM_FILE != table_info->m_file_type) continue; + const char * binfile = table_info->m_system_filename; + guint32 freq = 1; PhraseIndexRange range; int result = phrase_index.get_range(i, range); if ( result == ERROR_OK ) { diff --git a/utils/utils_helper.h b/utils/utils_helper.h index 29e776a..152807b 100644 --- a/utils/utils_helper.h +++ b/utils/utils_helper.h @@ -26,10 +26,13 @@ static bool load_phrase_index(FacadePhraseIndex * phrase_index) { MemoryChunk * chunk = NULL; for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { - const char * binfile = pinyin_phrase_files[i]; - if (NULL == binfile) + const pinyin_table_info_t * table_info = pinyin_phrase_files + i; + + if (SYSTEM_FILE != table_info->m_file_type) continue; + const char * binfile = table_info->m_system_filename; + chunk = new MemoryChunk; bool retval = chunk->load(binfile); if (!retval) { @@ -45,10 +48,13 @@ static bool load_phrase_index(FacadePhraseIndex * phrase_index) { static bool save_phrase_index(FacadePhraseIndex * phrase_index) { MemoryChunk * new_chunk = NULL; for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { - const char * binfile = pinyin_phrase_files[i]; - if (NULL == binfile) + const pinyin_table_info_t * table_info = pinyin_phrase_files + i; + + if (SYSTEM_FILE != table_info->m_file_type) continue; + const char * binfile = table_info->m_system_filename; + new_chunk = new MemoryChunk; phrase_index->store(i, new_chunk); bool retval = new_chunk->save(binfile); |