librime: unity_table_encoder.h Source File

| librime 1.2 Rime Input Method Engine, the core library

unity_table_encoder.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2013-08-31 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_UNITY_TABLE_ENCODER_H_
8#define RIME_UNITY_TABLE_ENCODER_H_
9
10#include <rime/common.h>
11#include <rime/algo/encoder.h>
12
13namespace rime {
14
15struct Ticket;
16class ReverseLookupDictionary;
17class UserDictionary;
18
19 class UnityTableEncoder : public TableEncoder, public PhraseCollector {
20 public:
21 UnityTableEncoder(UserDictionary* user_dict);
22 ~UnityTableEncoder();
23
24 bool Load(const Ticket& ticket);
25
26 void CreateEntry(const string& word,
27 const string& code_str,
28 const string& weight_str);
29 bool TranslateWord(const string& word, vector<string>* code);
30
31 size_t LookupPhrases(UserDictEntryIterator* result,
32 const string& input,
33 bool predictive,
34 size_t limit = 0,
35 string* resume_key = NULL);
36
37 static bool HasPrefix(const string& key);
38 static bool AddPrefix(string* key);
39 static bool RemovePrefix(string* key);
40
41 protected:
42 UserDictionary* user_dict_;
43 the<ReverseLookupDictionary> rev_dict_;
44};
45
46} // namespace rime
47
48#endif // RIME_UNITY_TABLE_ENCODER_H_
common.h
encoder.h
rime
Definition algebra.cc:12
rime::the
std::unique_ptr< T > the
Definition common.h:58
rime::PhraseCollector::PhraseCollector
PhraseCollector()=default
rime::TableEncoder::TableEncoder
TableEncoder(PhraseCollector *collector=NULL)
Definition encoder.cc:27
rime::ReverseLookupDictionary
Definition reverse_lookup_dictionary.h:64
rime::UserDictEntryIterator
Definition user_dictionary.h:18
rime::UserDictionary
Definition user_dictionary.h:49
rime::UnityTableEncoder::LookupPhrases
size_t LookupPhrases(UserDictEntryIterator *result, const string &input, bool predictive, size_t limit=0, string *resume_key=NULL)
Definition unity_table_encoder.cc:71
rime::UnityTableEncoder::AddPrefix
static bool AddPrefix(string *key)
Definition unity_table_encoder.cc:86
rime::UnityTableEncoder::user_dict_
UserDictionary * user_dict_
Definition unity_table_encoder.h:42
rime::UnityTableEncoder::HasPrefix
static bool HasPrefix(const string &key)
Definition unity_table_encoder.cc:82
rime::UnityTableEncoder::UnityTableEncoder
UnityTableEncoder(UserDictionary *user_dict)
Definition unity_table_encoder.cc:19
rime::UnityTableEncoder::CreateEntry
void CreateEntry(const string &word, const string &code_str, const string &weight_str)
Definition unity_table_encoder.cc:45
rime::UnityTableEncoder::Load
bool Load(const Ticket &ticket)
Definition unity_table_encoder.cc:26
rime::UnityTableEncoder::TranslateWord
bool TranslateWord(const string &word, vector< string > *code)
Definition unity_table_encoder.cc:57
rime::UnityTableEncoder::rev_dict_
the< ReverseLookupDictionary > rev_dict_
Definition unity_table_encoder.h:43
rime::UnityTableEncoder::RemovePrefix
static bool RemovePrefix(string *key)
Definition unity_table_encoder.cc:91
rime::Ticket
Definition ticket.h:17