From 2d42f29d97bcab3707365fdaa6df6920b2430ccb Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Sat, 20 Oct 2012 16:26:02 +0800 Subject: move get_first_token to spseg --- src/storage/phrase_large_table2.h | 23 ----------------------- utils/segment/spseg.cpp | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/storage/phrase_large_table2.h b/src/storage/phrase_large_table2.h index 6a73851..dd1a1e4 100644 --- a/src/storage/phrase_large_table2.h +++ b/src/storage/phrase_large_table2.h @@ -130,29 +130,6 @@ static inline int reduce_tokens(PhraseTokens tokens, return num; } -/* for compatibility. */ -static inline int get_first_token(PhraseTokens tokens, - /* out */ phrase_token_t & token){ - int num = 0; token = null_token; - - for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { - GArray * array = tokens[i]; - if (NULL == array || 0 == array->len) - continue; - - num += array->len; - - if (null_token == token) { - token = g_array_index(array, phrase_token_t, 0); - } - } - - /* the following line will be removed in future after code are verified. */ - assert(0 == num || 1 == num); - - return num; -} - }; #endif diff --git a/utils/segment/spseg.cpp b/utils/segment/spseg.cpp index b7d6176..6205369 100644 --- a/utils/segment/spseg.cpp +++ b/utils/segment/spseg.cpp @@ -26,6 +26,21 @@ #include "pinyin_internal.h" #include "utils_helper.h" +/* for compatibility. */ +int get_first_token(PhraseTokens tokens, + /* out */ phrase_token_t & token){ + token = null_token; + + GArray * tokenarray = g_array_new(FALSE, FALSE, sizeof(phrase_token_t)); + int num = reduce_tokens(tokens, tokenarray); + if (num) + token = g_array_index(tokenarray, phrase_token_t, 0); + g_array_free(tokenarray, TRUE); + + return num; +} + + /* graph shortest path sentence segment. */ /* Note: -- cgit