Skip to content

Commit 982f69d

Browse files
committed
fix(user_dictionary): make user phrases comparable in weight to system words
This avoids ordering issues between user/system words with contextual_suggestions: true.
1 parent 2b48531 commit 982f69d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/rime/dict/user_dictionary.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ an<DictEntry> UserDictionary::CreateDictEntry(const string& key,
485485
(double)v.commits / present_tick,
486486
(double)present_tick,
487487
v.dee);
488-
e->weight = log(weight > 0 ? weight : DBL_EPSILON) + credibility;
488+
constexpr double kUser = 13; // log(1e8) - log(200)
489+
e->weight = kUser + log(weight > 0 ? weight : DBL_EPSILON) + credibility;
489490
if (full_code) {
490491
*full_code = key.substr(0, separator_pos);
491492
}

src/rime/gear/script_translator.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ void ScriptTranslation::PrepareCandidate() {
503503
DictEntryIterator& iter(phrase_iter_->second);
504504
const auto& entry(iter.Peek());
505505
DLOG(INFO) << "phrase '" << entry->text
506-
<< "', code length: " << user_phrase_code_length;
506+
<< "', code length: " << phrase_code_length;
507507
cand = New<Phrase>(translator_->language(),
508508
"phrase",
509509
start_,

0 commit comments

Comments
 (0)