librime: script_translator.h Source File

| librime 1.2 Rime Input Method Engine, the core library

script_translator.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2011-08-07 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_SCRIPT_TRANSLATOR_H_
8#define RIME_SCRIPT_TRANSLATOR_H_
9
10#include <rime/common.h>
11#include <rime/translation.h>
12#include <rime/translator.h>
13#include <rime/algo/algebra.h>
14#include <rime/gear/memory.h>
15#include <rime/gear/translator_commons.h>
16
17namespace rime {
18
19class Code;
20class Corrector;
21struct DictEntry;
22class Dictionary;
23class Poet;
24class UserDictionary;
25struct SyllableGraph;
26
27 class ScriptTranslator : public Translator,
28 public Memory,
29 public TranslatorOptions {
30 public:
31 ScriptTranslator(const Ticket& ticket);
32
33 virtual an<Translation> Query(const string& input,
34 const Segment& segment) override;
35 virtual bool Memorize(const CommitEntry& commit_entry) override;
36 virtual bool ProcessSegmentOnCommit(CommitEntry& commit_entry,
37 const Segment& seg) override;
38
39 string FormatPreedit(const string& preedit);
40 string Spell(const Code& code);
41 string GetPrecedingText(size_t start) const;
42 bool UpdateElements(const CommitEntry& commit_entry);
43
44 bool ConcatenatePhrases(CommitEntry& commit_entry,
45 const vector<an<Phrase>>& phrases);
46 bool SaveCommitEntry(CommitEntry& commit_entry);
47
48 // options
49 int max_homophones() const { return max_homophones_; }
50 int spelling_hints() const { return spelling_hints_; }
51 bool always_show_comments() const { return always_show_comments_; }
52 bool enable_word_completion() const { return enable_word_completion_; }
53 int max_word_length() const { return max_word_length_; }
54 int core_word_length() const;
55
56 protected:
57 int max_homophones_ = 1;
58 int spelling_hints_ = 0;
59 int max_word_length_ = 0;
60 int core_word_length_ = 0;
61 bool always_show_comments_ = false;
62 bool enable_correction_ = false;
63 bool enable_word_completion_ = false;
64 the<Corrector> corrector_;
65 the<Poet> poet_;
66 vector<an<Phrase>> queue_;
67};
68
69} // namespace rime
70
71#endif // RIME_SCRIPT_TRANSLATOR_H_
algebra.h
common.h
memory.h
translator_commons.h
translation.h
translator.h
rime
Definition algebra.cc:12
rime::an
std::shared_ptr< T > an
Definition common.h:60
rime::the
std::unique_ptr< T > the
Definition common.h:58
rime::SyllableGraph
Definition syllabifier.h:39
rime::Corrector
Definition corrector.h:56
rime::Dictionary
Definition dictionary.h:62
rime::UserDictionary
Definition user_dictionary.h:49
rime::Code
Definition vocabulary.h:21
rime::DictEntry
Definition vocabulary.h:46
rime::CommitEntry
Definition memory.h:24
rime::Memory::Memory
Memory(const Ticket &ticket)
Definition memory.cc:58
rime::Poet
Definition poet.h:26
rime::ScriptTranslator::Query
virtual an< Translation > Query(const string &input, const Segment &segment) override
Definition script_translator.cc:207
rime::ScriptTranslator::max_word_length
int max_word_length() const
Definition script_translator.h:53
rime::ScriptTranslator::max_word_length_
int max_word_length_
Definition script_translator.h:59
rime::ScriptTranslator::always_show_comments_
bool always_show_comments_
Definition script_translator.h:61
rime::ScriptTranslator::ConcatenatePhrases
bool ConcatenatePhrases(CommitEntry &commit_entry, const vector< an< Phrase > > &phrases)
Definition script_translator.cc:257
rime::ScriptTranslator::Memorize
virtual bool Memorize(const CommitEntry &commit_entry) override
Definition script_translator.cc:344
rime::ScriptTranslator::max_homophones_
int max_homophones_
Definition script_translator.h:57
rime::ScriptTranslator::UpdateElements
bool UpdateElements(const CommitEntry &commit_entry)
Definition script_translator.cc:324
rime::ScriptTranslator::core_word_length
int core_word_length() const
Definition script_translator.cc:237
rime::ScriptTranslator::FormatPreedit
string FormatPreedit(const string &preedit)
Definition script_translator.cc:302
rime::ScriptTranslator::Spell
string Spell(const Code &code)
Definition script_translator.cc:308
rime::ScriptTranslator::enable_word_completion_
bool enable_word_completion_
Definition script_translator.h:63
rime::ScriptTranslator::ScriptTranslator
ScriptTranslator(const Ticket &ticket)
Definition script_translator.cc:182
rime::ScriptTranslator::spelling_hints
int spelling_hints() const
Definition script_translator.h:50
rime::ScriptTranslator::queue_
vector< an< Phrase > > queue_
Definition script_translator.h:66
rime::ScriptTranslator::poet_
the< Poet > poet_
Definition script_translator.h:65
rime::ScriptTranslator::enable_word_completion
bool enable_word_completion() const
Definition script_translator.h:52
rime::ScriptTranslator::GetPrecedingText
string GetPrecedingText(size_t start) const
Definition script_translator.cc:318
rime::ScriptTranslator::corrector_
the< Corrector > corrector_
Definition script_translator.h:64
rime::ScriptTranslator::ProcessSegmentOnCommit
virtual bool ProcessSegmentOnCommit(CommitEntry &commit_entry, const Segment &seg) override
Definition script_translator.cc:285
rime::ScriptTranslator::always_show_comments
bool always_show_comments() const
Definition script_translator.h:51
rime::ScriptTranslator::enable_correction_
bool enable_correction_
Definition script_translator.h:62
rime::ScriptTranslator::SaveCommitEntry
bool SaveCommitEntry(CommitEntry &commit_entry)
Definition script_translator.cc:248
rime::ScriptTranslator::spelling_hints_
int spelling_hints_
Definition script_translator.h:58
rime::ScriptTranslator::core_word_length_
int core_word_length_
Definition script_translator.h:60
rime::ScriptTranslator::max_homophones
int max_homophones() const
Definition script_translator.h:49
rime::TranslatorOptions::TranslatorOptions
TranslatorOptions(const Ticket &ticket)
Definition translator_commons.cc:115
rime::Segment
Definition segmentation.h:18
rime::Ticket
Definition ticket.h:17
rime::Translator::Translator
Translator(const Ticket &ticket)
Definition translator.h:24