summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-12-10 11:16:55 +0800
committerPeng Wu <alexepico@gmail.com>2011-12-10 11:16:55 +0800
commit44d567eee4767c7b0bc4a2feb8cb9faaf8c83019 (patch)
tree34bd21ac9b500e2b81b70cd7321c896620fdabe5
parent3af2cf9799894048f226e952ea9a0b06f5da6553 (diff)
downloadlibpinyin-44d567eee4767c7b0bc4a2feb8cb9faaf8c83019.zip
libpinyin-44d567eee4767c7b0bc4a2feb8cb9faaf8c83019.tar.gz
libpinyin-44d567eee4767c7b0bc4a2feb8cb9faaf8c83019.tar.xz
rename pinyin to pronunciation
-rw-r--r--src/lookup/pinyin_lookup.cpp8
-rw-r--r--src/pinyin.cpp4
-rw-r--r--src/storage/phrase_index.cpp2
-rw-r--r--src/storage/phrase_index.h4
-rw-r--r--tests/storage/test_phrase_index.cpp10
5 files changed, 14 insertions, 14 deletions
diff --git a/src/lookup/pinyin_lookup.cpp b/src/lookup/pinyin_lookup.cpp
index dab4b96..a01b28a 100644
--- a/src/lookup/pinyin_lookup.cpp
+++ b/src/lookup/pinyin_lookup.cpp
@@ -335,7 +335,7 @@ bool PinyinLookup::unigram_gen_next_step(int nstep, lookup_value_t * cur_step, p
m_phrase_index->get_phrase_index_total_freq();
if ( elem_poss < DBL_EPSILON )
return false;
- gfloat pinyin_poss = m_cache_phrase_item.get_pinyin_possibility(m_options, pinyinkeys);
+ gfloat pinyin_poss = m_cache_phrase_item.get_pronunciation_possibility(m_options, pinyinkeys);
if (pinyin_poss < FLT_EPSILON )
return false;
lookup_value_t next_step;
@@ -356,7 +356,7 @@ bool PinyinLookup::bigram_gen_next_step(int nstep, lookup_value_t * cur_step, ph
if ( bigram_poss < FLT_EPSILON && unigram_poss < DBL_EPSILON )
return false;
- gfloat pinyin_poss = m_cache_phrase_item.get_pinyin_possibility(m_options, pinyinkeys);
+ gfloat pinyin_poss = m_cache_phrase_item.get_pronunciation_possibility(m_options, pinyinkeys);
if ( pinyin_poss < FLT_EPSILON )
return false;
lookup_value_t next_step;
@@ -462,7 +462,7 @@ bool PinyinLookup::train_result(ChewingKeyVector keys, CandidateConstraints cons
//add pi-gram frequency
//printf("i:%d\tlast_token:%d\ttoken:%d\n", i, last_token, *token);
m_phrase_index->get_phrase_item(*token, m_cache_phrase_item);
- m_cache_phrase_item.increase_pinyin_possibility(m_options, pinyin_keys + i, train_factor);
+ m_cache_phrase_item.increase_pronunciation_possibility(m_options, pinyin_keys + i, train_factor);
m_phrase_index->add_unigram_frequency(*token, train_factor * 10);
if ( last_token ){
SingleGram * system, *user;
@@ -579,7 +579,7 @@ bool PinyinLookup::validate_constraint(CandidateConstraints constraints, Chewing
continue;
}
//clear invalidated pinyin
- gfloat pinyin_poss = m_cache_phrase_item.get_pinyin_possibility(m_options, pinyin_keys + i);
+ gfloat pinyin_poss = m_cache_phrase_item.get_pronunciation_possibility(m_options, pinyin_keys + i);
if ( pinyin_poss < FLT_EPSILON ){
clear_constraint(constraints, i);
}
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 604766d..a6d8b5c 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -394,10 +394,10 @@ static gint compare_token_with_unigram_freq(gconstpointer lhs,
PhraseItem item;
phrase_index->get_phrase_item(token_lhs, item);
guint32 freq_lhs = item.get_unigram_frequency() *
- item.get_pinyin_possibility(options, pinyin_keys) * 256;
+ item.get_pronunciation_possibility(options, pinyin_keys) * 256;
phrase_index->get_phrase_item(token_rhs, item);
guint32 freq_rhs = item.get_unigram_frequency() *
- item.get_pinyin_possibility(options, pinyin_keys) * 256;
+ item.get_pronunciation_possibility(options, pinyin_keys) * 256;
return -(freq_lhs - freq_rhs); /* in descendant order */
}
diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp
index 6409272..294cd00 100644
--- a/src/storage/phrase_index.cpp
+++ b/src/storage/phrase_index.cpp
@@ -69,7 +69,7 @@ bool PhraseItem::set_phrase_string(guint8 phrase_length, utf16_t * phrase){
return true;
}
-void PhraseItem::increase_pinyin_possibility(pinyin_option_t options,
+void PhraseItem::increase_pronunciation_possibility(pinyin_option_t options,
ChewingKey * keys,
gint32 delta){
guint8 phrase_length = get_phrase_length();
diff --git a/src/storage/phrase_index.h b/src/storage/phrase_index.h
index 69f39d9..c1ad870 100644
--- a/src/storage/phrase_index.h
+++ b/src/storage/phrase_index.h
@@ -90,7 +90,7 @@ public:
return (*(guint32 *)(buf_begin + sizeof(guint8) + sizeof(guint8)));
}
- gfloat get_pinyin_possibility(pinyin_option_t options,
+ gfloat get_pronunciation_possibility(pinyin_option_t options,
ChewingKey * keys){
guint8 phrase_length = get_phrase_length();
guint8 npron = get_n_pronunciation();
@@ -122,7 +122,7 @@ public:
return retval;
}
- void increase_pinyin_possibility(pinyin_option_t options,
+ void increase_pronunciation_possibility(pinyin_option_t options,
ChewingKey * keys,
gint32 delta);
diff --git a/tests/storage/test_phrase_index.cpp b/tests/storage/test_phrase_index.cpp
index 3692828..b883c9e 100644
--- a/tests/storage/test_phrase_index.cpp
+++ b/tests/storage/test_phrase_index.cpp
@@ -28,7 +28,7 @@ int main(int argc, char * argv[]){
assert(freq == 300);
pinyin_option_t options = 0;
- gfloat poss = phrase_item.get_pinyin_possibility(options, &key1);
+ gfloat poss = phrase_item.get_pronunciation_possibility(options, &key1);
printf("pinyin possiblitiy:%f\n", poss);
assert(phrase_item.get_unigram_frequency() == 0);
@@ -51,21 +51,21 @@ int main(int argc, char * argv[]){
assert(item2.get_unigram_frequency() == 0);
assert(item2.get_n_pronunciation() == 2);
assert(item2.get_phrase_length() == 1);
- assert(item2.get_pinyin_possibility(options, &key2) == 0.75);
+ assert(item2.get_pronunciation_possibility(options, &key2) == 0.75);
}
print_time(time, bench_times);
{
PhraseItem item3;
phrase_index.get_phrase_item(1, item3);
- item3.increase_pinyin_possibility(options, &key1, 200);
- assert(item3.get_pinyin_possibility(options, &key1) == 0.5) ;
+ item3.increase_pronunciation_possibility(options, &key1, 200);
+ assert(item3.get_pronunciation_possibility(options, &key1) == 0.5) ;
}
{
PhraseItem item5;
phrase_index.get_phrase_item(1, item5);
- gfloat poss = item5.get_pinyin_possibility(options, &key1);
+ gfloat poss = item5.get_pronunciation_possibility(options, &key1);
printf("pinyin poss:%f\n", poss);
assert(poss == 0.5);
}