void PhraseItem::remove_nth_pronunciation(size_t index){
guint8 phrase_length = get_phrase_length();
set_n_pronunciation(get_n_pronunciation() - 1);
- size_t offset = phrase_item_header + phrase_length * sizeof ( ucs4_t ) +
- index * (phrase_length * sizeof (ChewingKey) + sizeof(guint32));
+ size_t offset = phrase_item_header + phrase_length * sizeof(ucs4_t) +
+ index * (phrase_length * sizeof(ChewingKey) + sizeof(guint32));
m_chunk.remove_content(offset, phrase_length * sizeof(ChewingKey) + sizeof(guint32));
}
}
void PhraseItem::increase_pronunciation_possibility(pinyin_option_t options,
- ChewingKey * keys,
- gint32 delta){
+ ChewingKey * keys,
+ gint32 delta){
guint8 phrase_length = get_phrase_length();
guint8 npron = get_n_pronunciation();
size_t offset = phrase_item_header + phrase_length * sizeof ( ucs4_t );
return ERROR_OUT_OF_RANGE;
if ( 0 == offset )
- return ERROR_NO_ITEM;
+ return ERROR_NO_ITEM;
result = m_phrase_content.get_content
(offset + sizeof(guint8) + sizeof(guint8), &freq, sizeof(guint32));
if ( !result )
- return ERROR_FILE_CORRUPTION;
+ return ERROR_FILE_CORRUPTION;
//protect total_freq overflow
if ( delta > 0 && m_total_freq > m_total_freq + delta )
return ERROR_OUT_OF_RANGE;
if ( 0 == offset )
- return ERROR_NO_ITEM;
+ return ERROR_NO_ITEM;
result = m_phrase_content.get_content(offset, &phrase_length, sizeof(guint8));
if ( !result )
- return ERROR_FILE_CORRUPTION;
+ return ERROR_FILE_CORRUPTION;
result = m_phrase_content.get_content(offset+sizeof(guint8), &n_prons, sizeof(guint8));
if ( !result )
int result = get_phrase_item(token, old_item);
if (result != ERROR_OK)
- return result;
+ return result;
item = new PhraseItem;
//implictly copy data from m_chunk_content.
m_phrase_index.set_chunk(buf_begin + index_one,
index_two - 1 - index_one, NULL);
m_phrase_content.set_chunk(buf_begin + index_two,
- index_three - 1 - index_two, NULL);
+ index_three - 1 - index_two, NULL);
g_return_val_if_fail( index_three <= end, FALSE);
return true;
}
range.m_range_begin = std_lite::min(oldrange.m_range_begin,
currange.m_range_begin);
range.m_range_end = std_lite::max(oldrange.m_range_end,
- currange.m_range_end);
+ currange.m_range_end);
PhraseItem olditem, newitem;
for (phrase_token_t token = range.m_range_begin;
logger->append_record(LOG_ADD_RECORD, token,
NULL, &(newitem.m_chunk));
} else { /* both empty. */
- /* do nothing. */
+ /* do nothing. */
}
}
}
remove_phrase_item(token, tmpitem);
olditem.m_chunk.set_chunk(oldchunk.begin(), oldchunk.size(),
- NULL);
+ NULL);
if (olditem != *tmpitem)
return false;
delete tmpitem;
const table_offset_t * begin = (const table_offset_t *)m_phrase_index.begin();
const table_offset_t * end = (const table_offset_t *)m_phrase_index.end();
+ if (begin == end) {
+ /* skip empty sub phrase index. */
+ range.m_range_begin = 1;
+ range.m_range_end = 1;
+ return ERROR_OK;
+ }
+
/* remove trailing zeros. */
const table_offset_t * poffset = 0;
for (poffset = end - 1; poffset >= begin + 1; --poffset) {
namespace pinyin{
const pinyin_table_info_t pinyin_phrase_files[PHRASE_INDEX_LIBRARY_COUNT] =
{
- {NULL, NULL, NULL, NOT_USED},
- {"gb_char.table", "gb_char.bin", "gb_char.dbin", SYSTEM_FILE},
- {"gbk_char.table", "gbk_char.bin", "gbk_char.dbin", SYSTEM_FILE},
- {NULL, NULL, NULL, NOT_USED},
- {NULL, NULL, NULL, NOT_USED},
-
- {NULL, NULL, NULL, NOT_USED},
- {NULL, NULL, NULL, NOT_USED},
- {NULL, NULL, NULL, NOT_USED},
- {NULL, NULL, NULL, NOT_USED},
- {NULL, NULL, NULL, NOT_USED},
-
- {NULL, NULL, NULL, NOT_USED},
- {NULL, NULL, NULL, NOT_USED},
- {NULL, NULL, NULL, NOT_USED},
- {NULL, NULL, NULL, NOT_USED},
- {NULL, NULL, NULL, NOT_USED},
-
- {NULL, NULL, "user.bin", USER_FILE}
+ {RESERVED, NULL, NULL, NULL, NOT_USED},
+ {GB_DICTIONARY, "gb_char.table", "gb_char.bin", "gb_char.dbin", SYSTEM_FILE},
+ {GBK_DICTIONARY, "gbk_char.table", "gbk_char.bin", "gbk_char.dbin", SYSTEM_FILE},
+
+ {MERGED_DICTIONARY, "merged.table", "merged.bin", "merged.dbin", SYSTEM_FILE},
+
+ {ART_DICTIONARY, "art.table", "art.bin", "art.dbin", DICTIONARY},
+ {CULTURE_DICTIONARY, "culture.table", "culture.bin", "culture.dbin", DICTIONARY},
+ {ECONOMY_DICTIONARY, "economy.table", "economy.bin", "economy.dbin", DICTIONARY},
+ {GEOLOGY_DICTIONARY, "geology.table", "geology.bin", "geology.dbin", DICTIONARY},
+ {HISTORY_DICTIONARY, "history.table", "history.bin", "history.dbin", DICTIONARY},
+
+ {LIFE_DICTIONARY, "life.table", "life.bin", "life.dbin", DICTIONARY},
+ {NATURE_DICTIONARY, "nature.table", "nature.bin", "nature.dbin", DICTIONARY},
+ {SCITECH_DICTIONARY, "scitech.table", "scitech.bin", "scitech.dbin", DICTIONARY},
+ {SOCIETY_DICTIONARY, "society.table", "society.bin", "society.dbin", DICTIONARY},
+ {SPORT_DICTIONARY, "sport.table", "sport.bin", "sport.dbin", DICTIONARY},
+
+ {RESERVED1, NULL, NULL, NULL, NOT_USED},
+
+ {USER_DICTIONARY, NULL, NULL, "user.bin", USER_FILE}
};