summaryrefslogtreecommitdiffstats
path: root/src/storage/phrase_large_table.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2010-09-01 14:46:03 +0800
committerPeng Wu <alexepico@gmail.com>2010-09-01 14:46:03 +0800
commitadb921802288a80b216683aab0e454abfdd6fa00 (patch)
treed0bf1e7e9ca26150759d78c3a26c0a3f995aed3c /src/storage/phrase_large_table.cpp
parent846e8ee8f62be6018a1d10d4d303f41d89e8787e (diff)
downloadlibpinyin-adb921802288a80b216683aab0e454abfdd6fa00.tar.gz
libpinyin-adb921802288a80b216683aab0e454abfdd6fa00.tar.xz
libpinyin-adb921802288a80b216683aab0e454abfdd6fa00.zip
add load_text to phrase large table
Diffstat (limited to 'src/storage/phrase_large_table.cpp')
-rw-r--r--src/storage/phrase_large_table.cpp21
1 files changed, 21 insertions, 0 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;
+}