/
candidate.vala
90 lines (83 loc) · 2.85 KB
/
candidate.vala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Copyright (C) 2011-2014 Daiki Ueno <ueno@gnu.org>
* Copyright (C) 2011-2014 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Gee;
namespace Skk {
/**
* Object representing a candidate in dictionaries.
*/
public class Candidate : Object {
/**
* Midasi word which generated this candidate.
*/
public string midasi { get; private set; }
/**
* Flag to indicate whether this candidate is generated as a
* result of okuri-ari conversion.
*/
public bool okuri { get; private set; }
/**
* Base string value of the candidate.
*/
public string text { get; set; }
/**
* Optional annotation text associated with the candidate.
*/
public string? annotation { get; set; }
/**
* Output string shown instead of text.
*
* This is particularly useful to display a candidate of
* numeric conversion.
*/
public string output { get; set; }
/**
* Convert the candidate to string.
* @return a string representing the candidate
*/
public string to_string () {
if (annotation != null) {
return text + ";" + annotation;
} else {
return text;
}
}
/**
* Create a new Candidate.
*
* @param midasi midasi (index) word which generate the candidate
* @param okuri whether the candidate is a result of okuri-ari conversion
* @param text base string value of the candidate
* @param annotation optional annotation text to the candidate
* @param output optional output text used instead of text
*
* @return a new SkkCandidate
*/
public Candidate (string midasi,
bool okuri,
string text,
string? annotation = null,
string? output = null)
{
this.midasi = midasi;
this.okuri = okuri;
this.text = text;
this.annotation = annotation;
this.output = output == null ? text : output;
}
}
}