-
Notifications
You must be signed in to change notification settings - Fork 5
/
postype.go
140 lines (119 loc) · 2.18 KB
/
postype.go
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package kiwi
import "fmt"
type POSType string
// NOTE: update isValid function when adding a new POSType.
const (
POS_UNKNOWN POSType = "UNKNOWN"
POS_NNG POSType = "NNG"
POS_NNP POSType = "NNP"
POS_NNB POSType = "NNB"
POS_VV POSType = "VV"
POS_VA POSType = "VA"
POS_MAG POSType = "MAG"
POS_NR POSType = "NR"
POS_NP POSType = "NP"
POS_VX POSType = "VX"
POS_MM POSType = "MM"
POS_MAJ POSType = "MAJ"
POS_IC POSType = "IC"
POS_XPN POSType = "XPN"
POS_XSN POSType = "XSN"
POS_XSV POSType = "XSV"
POS_XSA POSType = "XSA"
POS_XR POSType = "XR"
POS_VCP POSType = "VCP"
POS_VCN POSType = "VCN"
POS_SF POSType = "SF"
POS_SP POSType = "SP"
POS_SS POSType = "SS"
POS_SE POSType = "SE"
POS_SO POSType = "SO"
POS_SW POSType = "SW"
POS_SL POSType = "SL"
POS_SH POSType = "SH"
POS_SN POSType = "SN"
POS_W_URL POSType = "W_URL"
POS_W_EMAIL POSType = "W_EMAIL"
POS_W_MENTION POSType = "W_MENTION"
POS_W_HASHTAG POSType = "W_HASHTAG"
POS_JKS POSType = "JKS"
POS_JKC POSType = "JKC"
POS_JKG POSType = "JKG"
POS_JKO POSType = "JKO"
POS_JKB POSType = "JKB"
POS_JKV POSType = "JKV"
POS_JKQ POSType = "JKQ"
POS_JX POSType = "JX"
POS_JC POSType = "JC"
POS_EP POSType = "EP"
POS_EF POSType = "EF"
POS_EC POSType = "EC"
POS_ETN POSType = "ETN"
POS_ETM POSType = "ETM"
POS_V POSType = "V"
POS_MAX POSType = "MAX"
)
func (p POSType) isValid() bool {
switch p {
case POS_UNKNOWN,
POS_NNG,
POS_NNP,
POS_NNB,
POS_VV,
POS_VA,
POS_MAG,
POS_NR,
POS_NP,
POS_VX,
POS_MM,
POS_MAJ,
POS_IC,
POS_XPN,
POS_XSN,
POS_XSV,
POS_XSA,
POS_XR,
POS_VCP,
POS_VCN,
POS_SF,
POS_SP,
POS_SS,
POS_SE,
POS_SO,
POS_SW,
POS_SL,
POS_SH,
POS_SN,
POS_W_URL,
POS_W_EMAIL,
POS_W_MENTION,
POS_W_HASHTAG,
POS_JKS,
POS_JKC,
POS_JKG,
POS_JKO,
POS_JKB,
POS_JKV,
POS_JKQ,
POS_JX,
POS_JC,
POS_EP,
POS_EF,
POS_EC,
POS_ETN,
POS_ETM,
POS_V,
POS_MAX:
return true
default:
return false
}
}
// ParsePOSType return POS Tag for resault
func ParsePOSType(t string) (POSType, error) {
pos := POSType(t)
if !pos.isValid() {
return POS_UNKNOWN, fmt.Errorf("POS type parse err. input type: %s", t)
}
return pos, nil
}