librime: spelling.h Source File

| librime 1.2 Rime Input Method Engine, the core library

spelling.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2012-01-17 GONG Chen <chen.sst@gmail.com>
6//
7
8#ifndef RIME_SPELLING_H_
9#define RIME_SPELLING_H_
10
11#include <rime/common.h>
12
13namespace rime {
14
15 enum SpellingType {
16 kNormalSpelling,
17 kFuzzySpelling,
18 kAbbreviation,
19 kCompletion,
20 kAmbiguousSpelling,
21 kInvalidSpelling
22};
23
24 struct SpellingProperties {
25 SpellingType type = kNormalSpelling;
26 size_t end_pos = 0;
27 double credibility = 0.0;
28 string tips;
29 bool is_correction = false;
30
31 // 疊加運算規則, 將運算規則產生的屬性應用到當前拼寫上
32 void Compose(const SpellingProperties& delta);
33 // 更新優化拼寫, 將另一個候選拼寫合併到當前記錄
34 void Update(const SpellingProperties& other);
35};
36
37 struct Spelling {
38 string str;
39 SpellingProperties properties;
40
41 Spelling() = default;
42 Spelling(const string& _str) : str(_str) {}
43
44 bool operator==(const Spelling& other) { return str == other.str; }
45 bool operator<(const Spelling& other) { return str < other.str; }
46};
47
48} // namespace rime
49
50#endif // RIME_SPELLING_H_
common.h
rime
Definition algebra.cc:12
rime::SpellingType
SpellingType
Definition spelling.h:15
rime::kAbbreviation
@ kAbbreviation
Definition spelling.h:18
rime::kInvalidSpelling
@ kInvalidSpelling
Definition spelling.h:21
rime::kNormalSpelling
@ kNormalSpelling
Definition spelling.h:16
rime::kFuzzySpelling
@ kFuzzySpelling
Definition spelling.h:17
rime::kAmbiguousSpelling
@ kAmbiguousSpelling
Definition spelling.h:20
rime::kCompletion
@ kCompletion
Definition spelling.h:19
rime::SpellingProperties
Definition spelling.h:24
rime::SpellingProperties::Update
void Update(const SpellingProperties &other)
Definition spelling.cc:22
rime::SpellingProperties::type
SpellingType type
Definition spelling.h:25
rime::SpellingProperties::end_pos
size_t end_pos
Definition spelling.h:26
rime::SpellingProperties::is_correction
bool is_correction
Definition spelling.h:29
rime::SpellingProperties::credibility
double credibility
Definition spelling.h:27
rime::SpellingProperties::tips
string tips
Definition spelling.h:28
rime::SpellingProperties::Compose
void Compose(const SpellingProperties &delta)
Definition spelling.cc:5
rime::Spelling::operator<
bool operator<(const Spelling &other)
Definition spelling.h:45
rime::Spelling::Spelling
Spelling(const string &_str)
Definition spelling.h:42
rime::Spelling::operator==
bool operator==(const Spelling &other)
Definition spelling.h:44
rime::Spelling::Spelling
Spelling()=default
rime::Spelling::str
string str
Definition spelling.h:38
rime::Spelling::properties
SpellingProperties properties
Definition spelling.h:39