librime: simplifier.h Source File

| librime 1.2 Rime Input Method Engine, the core library

simplifier.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2011-12-12 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_SIMPLIFIER_H_
8#define RIME_SIMPLIFIER_H_
9
10#include <rime/filter.h>
11#include <rime/algo/algebra.h>
12#include <rime/gear/filter_commons.h>
13
14namespace rime {
15
16class Opencc;
17
18 class Simplifier : public Filter, TagMatching {
19 public:
20 Simplifier(const Ticket& ticket, an<Opencc> opencc);
21
22 virtual an<Translation> Apply(an<Translation> translation,
23 CandidateList* candidates);
24
25 virtual bool AppliesToSegment(Segment* segment) { return TagsMatch(segment); }
26
27 bool Convert(const an<Candidate>& original, CandidateQueue* result);
28
29 protected:
30 enum TipsLevel { kTipsNone, kTipsChar, kTipsAll };
31
32 void PushBack(const an<Candidate>& original,
33 CandidateQueue* result,
34 const string& simplified);
35
36 an<Opencc> opencc_;
37 // settings
38 TipsLevel tips_level_ = kTipsNone;
39 string option_name_;
40 set<string> excluded_types_;
41 bool show_in_comment_ = false;
42 bool inherit_comment_ = true;
43 Projection comment_formatter_;
44 bool random_ = false;
45};
46
47 class SimplifierComponent : public Simplifier::Component {
48 public:
49 SimplifierComponent();
50 Simplifier* Create(const Ticket& ticket);
51
52 private:
53 hash_map<string, weak<Opencc>> opencc_map_;
54};
55
56} // namespace rime
57
58#endif // RIME_SIMPLIFIER_H_
filter.h
filter_commons.h
algebra.h
rime
Definition algebra.cc:12
rime::an
std::shared_ptr< T > an
Definition common.h:60
rime::CandidateQueue
list< of< Candidate > > CandidateQueue
Definition candidate.h:51
rime::hash_map
boost::unordered_map< Key, T > hash_map
Definition common.h:53
rime::CandidateList
vector< of< Candidate > > CandidateList
Definition candidate.h:52
rime::Projection
Definition algebra.h:29
rime::Filter::Filter
Filter(const Ticket &ticket)
Definition filter.h:24
rime::TagMatching::TagMatching
TagMatching(const Ticket &ticket)
Definition filter_commons.cc:14
rime::TagMatching::TagsMatch
bool TagsMatch(Segment *segment)
Definition filter_commons.cc:27
rime::Opencc
Definition simplifier.cc:32
rime::Simplifier
Definition simplifier.h:18
rime::Simplifier::tips_level_
TipsLevel tips_level_
Definition simplifier.h:38
rime::Simplifier::PushBack
void PushBack(const an< Candidate > &original, CandidateQueue *result, const string &simplified)
Definition simplifier.cc:234
rime::Simplifier::inherit_comment_
bool inherit_comment_
Definition simplifier.h:42
rime::Simplifier::option_name_
string option_name_
Definition simplifier.h:39
rime::Simplifier::Simplifier
Simplifier(const Ticket &ticket, an< Opencc > opencc)
Definition simplifier.cc:169
rime::Simplifier::random_
bool random_
Definition simplifier.h:44
rime::Simplifier::excluded_types_
set< string > excluded_types_
Definition simplifier.h:40
rime::Simplifier::TipsLevel
TipsLevel
Definition simplifier.h:30
rime::Simplifier::kTipsNone
@ kTipsNone
Definition simplifier.h:30
rime::Simplifier::kTipsAll
@ kTipsAll
Definition simplifier.h:30
rime::Simplifier::kTipsChar
@ kTipsChar
Definition simplifier.h:30
rime::Simplifier::opencc_
an< Opencc > opencc_
Definition simplifier.h:36
rime::Simplifier::Apply
virtual an< Translation > Apply(an< Translation > translation, CandidateList *candidates)
Definition simplifier.cc:223
rime::Simplifier::comment_formatter_
Projection comment_formatter_
Definition simplifier.h:43
rime::Simplifier::show_in_comment_
bool show_in_comment_
Definition simplifier.h:41
rime::Simplifier::AppliesToSegment
virtual bool AppliesToSegment(Segment *segment)
Definition simplifier.h:25
rime::Simplifier::Convert
bool Convert(const an< Candidate > &original, CandidateQueue *result)
Definition simplifier.cc:264
rime::SimplifierComponent::Create
Simplifier * Create(const Ticket &ticket)
Definition simplifier.cc:300
rime::SimplifierComponent::SimplifierComponent
SimplifierComponent()
Definition simplifier.cc:298
rime::Segment
Definition segmentation.h:18
rime::Ticket
Definition ticket.h:17