Skip to content

Commit

Permalink
(script_translator): add config translator/enable_word_completion
Browse files Browse the repository at this point in the history
If unspecified, falls back to `translator/enable_completion`.

Fixed #905
  • Loading branch information
lotem committed Jul 31, 2024
1 parent 7bfde7b commit 0cdce16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/rime/gear/script_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ ScriptTranslator::ScriptTranslator(const Ticket& ticket)
config->GetBool(name_space_ + "/always_show_comments",
&always_show_comments_);
config->GetBool(name_space_ + "/enable_correction", &enable_correction_);
if (!config->GetBool(name_space_ + "/enable_word_completion",
&enable_word_completion_)) {
enable_word_completion_ = enable_completion_;
}
config->GetInt(name_space_ + "/max_homophones", &max_homophones_);
poet_.reset(new Poet(language(), config));
}
Expand Down Expand Up @@ -361,8 +365,8 @@ static bool has_exact_match_phrase(Ptr ptr, Iter iter, size_t consumed) {
bool ScriptTranslation::Evaluate(Dictionary* dict, UserDictionary* user_dict) {
size_t consumed = syllabifier_->BuildSyllableGraph(*dict->prism());
const auto& syllable_graph = syllabifier_->syllable_graph();
bool predict_word =
translator_->enable_completion() && start_ + consumed == end_of_input_;
bool predict_word = translator_->enable_word_completion() &&
start_ + consumed == end_of_input_;

phrase_ = dict->Lookup(syllable_graph, 0, predict_word);
if (user_dict) {
Expand Down
2 changes: 2 additions & 0 deletions src/rime/gear/script_translator.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class ScriptTranslator : public Translator,
int max_homophones() const { return max_homophones_; }
int spelling_hints() const { return spelling_hints_; }
bool always_show_comments() const { return always_show_comments_; }
bool enable_word_completion() const { return enable_word_completion_; }

protected:
int max_homophones_ = 1;
int spelling_hints_ = 0;
bool always_show_comments_ = false;
bool enable_correction_ = false;
bool enable_word_completion_ = false;
the<Corrector> corrector_;
the<Poet> poet_;
};
Expand Down

0 comments on commit 0cdce16

Please sign in to comment.