librime: preset_vocabulary.h Source File

| librime 1.2 Rime Input Method Engine, the core library

preset_vocabulary.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2011-11-27 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef PRESET_VOCABULARY_H_
8#define PRESET_VOCABULARY_H_
9
10#include <rime/common.h>
11
12namespace rime {
13
14struct VocabularyDb;
15
16 class PresetVocabulary {
17 public:
18 explicit PresetVocabulary(const string& vocabulary);
19 ~PresetVocabulary();
20
21 // random access
22 bool GetWeightForEntry(const string& key, double* weight);
23 // traversing
24 void Reset();
25 bool GetNextEntry(string* key, string* value);
26 bool IsQualifiedPhrase(const string& phrase, const string& weight_str);
27
28 void set_max_phrase_length(int length) { max_phrase_length_ = length; }
29 void set_min_phrase_weight(double weight) { min_phrase_weight_ = weight; }
30
31 static path DictFilePath(const string& vacabulary);
32
33 protected:
34 the<VocabularyDb> db_;
35 int max_phrase_length_ = 0;
36 double min_phrase_weight_ = 0.0;
37};
38
39} // namespace rime
40
41#endif // PRESET_VOCABULARY_H_
common.h
rime
Definition algebra.cc:12
rime::the
std::unique_ptr< T > the
Definition common.h:58
rime::path
Definition common.h:84
rime::VocabularyDb
Definition preset_vocabulary.cc:17
rime::PresetVocabulary::Reset
void Reset()
Definition preset_vocabulary.cc:85
rime::PresetVocabulary::set_min_phrase_weight
void set_min_phrase_weight(double weight)
Definition preset_vocabulary.h:29
rime::PresetVocabulary::db_
the< VocabularyDb > db_
Definition preset_vocabulary.h:34
rime::PresetVocabulary::PresetVocabulary
PresetVocabulary(const string &vocabulary)
Definition preset_vocabulary.cc:61
rime::PresetVocabulary::GetNextEntry
bool GetNextEntry(string *key, string *value)
Definition preset_vocabulary.cc:90
rime::PresetVocabulary::IsQualifiedPhrase
bool IsQualifiedPhrase(const string &phrase, const string &weight_str)
Definition preset_vocabulary.cc:100
rime::PresetVocabulary::GetWeightForEntry
bool GetWeightForEntry(const string &key, double *weight)
Definition preset_vocabulary.cc:73
rime::PresetVocabulary::DictFilePath
static path DictFilePath(const string &vacabulary)
Definition preset_vocabulary.cc:55
rime::PresetVocabulary::max_phrase_length_
int max_phrase_length_
Definition preset_vocabulary.h:35
rime::PresetVocabulary::min_phrase_weight_
double min_phrase_weight_
Definition preset_vocabulary.h:36
rime::PresetVocabulary::set_max_phrase_length
void set_max_phrase_length(int length)
Definition preset_vocabulary.h:28