summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-05-26 12:04:43 +0800
committerPeng Wu <alexepico@gmail.com>2016-05-26 12:04:43 +0800
commitc57ac3f8e10e8c39053ca614277ee0fa671afef4 (patch)
treedd325e369658670248e5ca0a3fc99d4131240afa
parentcba509e211af9432573362825ae66fa8eb41fdd5 (diff)
downloadlibpinyin-c57ac3f8e10e8c39053ca614277ee0fa671afef4.tar.gz
libpinyin-c57ac3f8e10e8c39053ca614277ee0fa671afef4.tar.xz
libpinyin-c57ac3f8e10e8c39053ca614277ee0fa671afef4.zip
fixes indent
-rw-r--r--src/lookup/pinyin_lookup2.cpp82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/lookup/pinyin_lookup2.cpp b/src/lookup/pinyin_lookup2.cpp
index f11756f..ce4f6eb 100644
--- a/src/lookup/pinyin_lookup2.cpp
+++ b/src/lookup/pinyin_lookup2.cpp
@@ -612,10 +612,10 @@ bool PinyinLookup2::train_result2(ChewingKeyVector keys,
}
/* train uni-gram */
- m_phrase_index->get_phrase_item(*token, m_cached_phrase_item);
- m_cached_phrase_item.increase_pronunciation_possibility
+ m_phrase_index->get_phrase_item(*token, m_cached_phrase_item);
+ m_cached_phrase_item.increase_pronunciation_possibility
(m_options, pinyin_keys + i, seed * pinyin_factor);
- m_phrase_index->add_unigram_frequency
+ m_phrase_index->add_unigram_frequency
(*token, seed * unigram_factor);
}
last_token = *token;
@@ -629,14 +629,14 @@ int PinyinLookup2::add_constraint(CandidateConstraints constraints,
phrase_token_t token) {
if (m_phrase_index->get_phrase_item(token, m_cached_phrase_item))
- return 0;
+ return 0;
size_t phrase_length = m_cached_phrase_item.get_phrase_length();
if ( index + phrase_length > constraints->len )
- return 0;
+ return 0;
for (size_t i = index; i < index + phrase_length; ++i){
- clear_constraint(constraints, i);
+ clear_constraint(constraints, i);
}
/* store one step constraint */
@@ -647,28 +647,28 @@ int PinyinLookup2::add_constraint(CandidateConstraints constraints,
/* propagate no search constraint */
for (size_t i = 1; i < phrase_length; ++i){
- constraint = &g_array_index(constraints, lookup_constraint_t, index + i);
- constraint->m_type = CONSTRAINT_NOSEARCH;
- constraint->m_constraint_step = index;
+ constraint = &g_array_index(constraints, lookup_constraint_t, index + i);
+ constraint->m_type = CONSTRAINT_NOSEARCH;
+ constraint->m_constraint_step = index;
}
return phrase_length;
}
bool PinyinLookup2::clear_constraint(CandidateConstraints constraints,
- int index) {
+ int index) {
if (index < 0 || index >= constraints->len)
- return false;
+ return false;
lookup_constraint_t * constraint = &g_array_index
(constraints, lookup_constraint_t, index);
if (NO_CONSTRAINT == constraint->m_type)
- return false;
+ return false;
if (CONSTRAINT_NOSEARCH == constraint->m_type){
- index = constraint->m_constraint_step;
- constraint = &g_array_index(constraints, lookup_constraint_t, index);
+ index = constraint->m_constraint_step;
+ constraint = &g_array_index(constraints, lookup_constraint_t, index);
}
/* now var constraint points to the one step constraint. */
@@ -676,16 +676,16 @@ bool PinyinLookup2::clear_constraint(CandidateConstraints constraints,
phrase_token_t token = constraint->m_token;
if (m_phrase_index->get_phrase_item(token, m_cached_phrase_item))
- return false;
+ return false;
size_t phrase_length = m_cached_phrase_item.get_phrase_length();
for ( size_t i = 0; i < phrase_length; ++i){
- if (index + i >= constraints->len)
- continue;
+ if (index + i >= constraints->len)
+ continue;
- constraint = &g_array_index
+ constraint = &g_array_index
(constraints, lookup_constraint_t, index + i);
- constraint->m_type = NO_CONSTRAINT;
+ constraint->m_type = NO_CONSTRAINT;
}
return true;
@@ -697,42 +697,42 @@ bool PinyinLookup2::validate_constraint(CandidateConstraints constraints,
size_t constraints_length = constraints->len;
if ( keys->len > constraints_length ){
- g_array_set_size(constraints, keys->len);
+ g_array_set_size(constraints, keys->len);
- /* initialize new element */
- for( size_t i = constraints_length; i < keys->len; ++i){
- lookup_constraint_t * constraint = &g_array_index(constraints, lookup_constraint_t, i);
- constraint->m_type = NO_CONSTRAINT;
- }
+ /* initialize new element */
+ for( size_t i = constraints_length; i < keys->len; ++i){
+ lookup_constraint_t * constraint = &g_array_index(constraints, lookup_constraint_t, i);
+ constraint->m_type = NO_CONSTRAINT;
+ }
}else if (keys->len < constraints_length ){
/* just shrink it */
- g_array_set_size(constraints, keys->len);
+ g_array_set_size(constraints, keys->len);
}
for ( size_t i = 0; i < constraints->len; ++i){
- lookup_constraint_t * constraint = &g_array_index
+ lookup_constraint_t * constraint = &g_array_index
(constraints, lookup_constraint_t, i);
/* handle one step constraint */
- if ( constraint->m_type == CONSTRAINT_ONESTEP ){
+ if ( constraint->m_type == CONSTRAINT_ONESTEP ){
- phrase_token_t token = constraint->m_token;
- m_phrase_index->get_phrase_item(token, m_cached_phrase_item);
- size_t phrase_length = m_cached_phrase_item.get_phrase_length();
+ phrase_token_t token = constraint->m_token;
+ m_phrase_index->get_phrase_item(token, m_cached_phrase_item);
+ size_t phrase_length = m_cached_phrase_item.get_phrase_length();
- /* clear too long constraint */
- if (i + phrase_length > constraints->len){
- clear_constraint(constraints, i);
- continue;
- }
+ /* clear too long constraint */
+ if (i + phrase_length > constraints->len){
+ clear_constraint(constraints, i);
+ continue;
+ }
ChewingKey * pinyin_keys = (ChewingKey *)keys->data;
- /* clear invalid pinyin */
- gfloat pinyin_poss = m_cached_phrase_item.get_pronunciation_possibility(m_options, pinyin_keys + i);
- if (pinyin_poss < FLT_EPSILON)
- clear_constraint(constraints, i);
- }
+ /* clear invalid pinyin */
+ gfloat pinyin_poss = m_cached_phrase_item.get_pronunciation_possibility(m_options, pinyin_keys + i);
+ if (pinyin_poss < FLT_EPSILON)
+ clear_constraint(constraints, i);
+ }
}
return true;
}