librime: charset_filter.h Source File

| librime 1.2 Rime Input Method Engine, the core library

charset_filter.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2014-03-31 Chongyu Zhu <i@lembacon.com>
6// 2019-12-26 Chen Gong <chen.sst@gmail.com> reduced to basic implementation
7//
8#ifndef RIME_CHARSET_FILTER_H_
9#define RIME_CHARSET_FILTER_H_
10
11#include <rime_api.h>
12#include <rime/filter.h>
13#include <rime/translation.h>
14#include <rime/gear/filter_commons.h>
15
16namespace rime {
17
18 class CharsetFilterTranslation : public Translation {
19 public:
20 explicit CharsetFilterTranslation(an<Translation> translation);
21 virtual bool Next();
22 virtual an<Candidate> Peek();
23
24 protected:
25 virtual bool FilterCandidate(an<Candidate> cand);
26
27 bool LocateNextCandidate();
28
29 an<Translation> translation_;
30};
31
32struct DictEntry;
33
34 class CharsetFilter : public Filter, TagMatching {
35 public:
36 explicit CharsetFilter(const Ticket& ticket);
37
38 virtual an<Translation> Apply(an<Translation> translation,
39 CandidateList* candidates);
40
41 virtual bool AppliesToSegment(Segment* segment) { return TagsMatch(segment); }
42
43 // return true to accept, false to reject the tested item
44 static bool FilterText(const string& text);
45 static bool FilterDictEntry(an<DictEntry> entry);
46};
47
48} // namespace rime
49
50#endif // RIME_CHARSET_FILTER_H_
rime_api.h
translation.h
filter.h
filter_commons.h
rime
Definition algebra.cc:12
rime::an
std::shared_ptr< T > an
Definition common.h:60
rime::CandidateList
vector< of< Candidate > > CandidateList
Definition candidate.h:52
rime::DictEntry
Definition vocabulary.h:46
rime::Filter::Filter
Filter(const Ticket &ticket)
Definition filter.h:24
rime::CharsetFilterTranslation::Peek
virtual an< Candidate > Peek()
Definition charset_filter.cc:69
rime::CharsetFilterTranslation::FilterCandidate
virtual bool FilterCandidate(an< Candidate > cand)
Definition charset_filter.cc:73
rime::CharsetFilterTranslation::Next
virtual bool Next()
Definition charset_filter.cc:59
rime::CharsetFilterTranslation::CharsetFilterTranslation
CharsetFilterTranslation(an< Translation > translation)
Definition charset_filter.cc:54
rime::CharsetFilterTranslation::translation_
an< Translation > translation_
Definition charset_filter.h:29
rime::CharsetFilterTranslation::LocateNextCandidate
bool LocateNextCandidate()
Definition charset_filter.cc:77
rime::CharsetFilter::AppliesToSegment
virtual bool AppliesToSegment(Segment *segment)
Definition charset_filter.h:41
rime::CharsetFilter::FilterText
static bool FilterText(const string &text)
Definition charset_filter.cc:90
rime::CharsetFilter::CharsetFilter
CharsetFilter(const Ticket &ticket)
Definition charset_filter.cc:98
rime::CharsetFilter::FilterDictEntry
static bool FilterDictEntry(an< DictEntry > entry)
Definition charset_filter.cc:94
rime::CharsetFilter::Apply
virtual an< Translation > Apply(an< Translation > translation, CandidateList *candidates)
Definition charset_filter.cc:101
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::Segment
Definition segmentation.h:18
rime::Ticket
Definition ticket.h:17
rime::Translation::Translation
Translation()=default