Skip to content

Commit

Permalink
fix(user_dictionary): make user phrases comparable in weight to syste…
Browse files Browse the repository at this point in the history
…m words

This avoids ordering issues between user/system words with contextual_suggestions: true.
  • Loading branch information
lotem committed Jun 15, 2019
1 parent 2b48531 commit 982f69d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/rime/dict/user_dictionary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ an<DictEntry> UserDictionary::CreateDictEntry(const string& key,
(double)v.commits / present_tick,
(double)present_tick,
v.dee);
e->weight = log(weight > 0 ? weight : DBL_EPSILON) + credibility;
constexpr double kUser = 13; // log(1e8) - log(200)
e->weight = kUser + log(weight > 0 ? weight : DBL_EPSILON) + credibility;
if (full_code) {
*full_code = key.substr(0, separator_pos);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rime/gear/script_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ void ScriptTranslation::PrepareCandidate() {
DictEntryIterator& iter(phrase_iter_->second);
const auto& entry(iter.Peek());
DLOG(INFO) << "phrase '" << entry->text
<< "', code length: " << user_phrase_code_length;
<< "', code length: " << phrase_code_length;
cand = New<Phrase>(translator_->language(),
"phrase",
start_,
Expand Down

0 comments on commit 982f69d

Please sign in to comment.