-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmecabnode.h
72 lines (55 loc) · 1.75 KB
/
mecabnode.h
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
#ifndef MECABNODE_H
#define MECABNODE_H
#include <QStringList>
#include <mecab.h>
const QString MeCabUnkownFeature;
class MeCabNode
{
public:
typedef QList<MeCabNode> MeCabResult;
~MeCabNode();
bool isUnknown() const;
QString surface() const
{ return this->surface_; }
QString feature() const
{ return this->feature_; }
int cost() const
{ return this->cost_; }
// features
QString parts() const
{ return this->get_feature(0); }
QString parts_detail1() const
{ return this->get_feature(1); }
QString parts_detail2() const
{ return this->get_feature(2); }
QString parts_detail3() const
{ return this->get_feature(3); }
QStringList parts_details() const
{ return {this->parts_detail1(), this->parts_detail2(), this->parts_detail3()}; }
QString conjugated_form() const
{ return this->get_feature(4); }
QString conjugated_type() const
{ return this->get_feature(5); }
QString prototype() const
{ return this->get_feature(6); }
QString kana() const
{ return this->get_feature(7); }
QString speech() const
{ return this->get_feature(8); }
bool hasKana() const
{ return ! this->kana().isEmpty(); }
bool hasSpeech() const
{ return ! this->speech().isEmpty(); }
static MeCabNode create(const MeCab::Node *node);
static MeCabNode create_dummy(const QString &surface, const QString &feature, int cost=-1);
static MeCabResult create_nodes(const MeCab::Node *node);
private:
MeCabNode(const QString &surface, const QString &feature, int cost);
QString get_feature(int index) const;
QString surface_;
QString feature_;
QStringList features_;
int cost_;
};
typedef MeCabNode::MeCabResult MeCabResult;
#endif // MECABNODE_H