diff options
Diffstat (limited to 'src/storage')
-rw-r--r-- | src/storage/phrase_large_table.cpp | 21 | ||||
-rw-r--r-- | src/storage/pinyin_large_table.cpp | 3 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/storage/phrase_large_table.cpp b/src/storage/phrase_large_table.cpp index a036263..d8810d3 100644 --- a/src/storage/phrase_large_table.cpp +++ b/src/storage/phrase_large_table.cpp @@ -311,3 +311,24 @@ int PhraseArrayIndexLevel<phrase_length>::remove_index(/* in */ utf16_t phrase[] m_chunk.remove_content(offset, sizeof (PhraseIndexItem<phrase_length>)); return REMOVE_OK; } + +bool PhraseLargeTable::load_text(FILE * infile){ + char pinyin[256]; + char phrase[256]; + phrase_token_t token; + size_t freq; + + while ( !feof(infile) ){ + fscanf(infile, "%s", pinyin); + fscanf(infile, "%s", phrase); + fscanf(infile, "%ld", &token); + fscanf(infile, "%ld", &freq); + + glong phrase_len = g_utf8_strlen(phrase, -1); + utf16_t * new_phrase = g_utf8_to_utf16(phrase, -1, NULL, NULL, NULL); + add_index(phrase_len, new_phrase, token); + + g_free(new_phrase); + } + return true; +} diff --git a/src/storage/pinyin_large_table.cpp b/src/storage/pinyin_large_table.cpp index f05317c..07f643e 100644 --- a/src/storage/pinyin_large_table.cpp +++ b/src/storage/pinyin_large_table.cpp @@ -482,6 +482,7 @@ bool PinyinLargeTable::load_text(FILE * infile){ char phrase[256]; phrase_token_t token; size_t freq; + while ( !feof(infile)){ fscanf(infile, "%s", pinyin); fscanf(infile, "%s", phrase); @@ -502,7 +503,7 @@ bool PinyinLargeTable::load_text(FILE * infile){ g_array_free(keys, true); g_array_free(poses, true); } - return true; + return true; } bool PinyinBitmapIndexLevel::load(MemoryChunk * chunk, table_offset_t offset, |