-
Notifications
You must be signed in to change notification settings - Fork 15
/
POSTag_stanford.go
128 lines (117 loc) · 4.02 KB
/
POSTag_stanford.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
// +build stanfordtags
package lingo
//go:generate stringer -type=POSTag -output=POSTag_stanford_string.go
const BUILD_TAGSET = "stanfordtags"
const (
X POSTag = iota // aka NULLTAG
UNKNOWN_TAG // Unknown
ROOT_TAG // For Root
CC // Coordinating conjunction
CD // Cardinal number
DT // Determiner
EX // Existential there
FW // Foreign word
IN // Preposition or subordinating conjunction
JJ // Adjective
JJR // Adjective, comparative
JJS // Adjective, superlative
LS // List item marker
MD // Modal
NN // Noun, singular or mass
NNS // Noun, plural
NNP // Proper noun, singular
NNPS // Proper noun, plural
PDT // Predeterminer
POS // Possessive ending
PRP // Personal pronoun
PPRP // Possessive pronoun (PRP$)
RB // Adverb
RBR // Adverb, comparative
RBS // Adverb, superlative
RP // Particle
SYM // Symbol
TO // to
UH // Interjection
VB // Verb, base form
VBD // Verb, past tense
VBG // Verb, gerund or present participle
VBN // Verb, past participle
VBP // Verb, non-3rd person singular present
VBZ // Verb, 3rd person singular present
WDT // Wh-determiner
WP // Wh-pronoun
PWP // Possessive wh-pronoun (WP$)
WRB // Wh-adverb
// Punctuation related stuff: http://stackoverflow.com/a/21546294
COMMA // Obvious isn't it?
FULLSTOP // fullstop
OPENQUOTE // Penn Treebank uses ``
CLOSEQUOTE // Penn Treebank uses ''
COLON
DOLLAR
HASHSIGN
LEFTBRACE
RIGHTBRACE
// Extensions for web shit: https://www.ldc.upenn.edu/sites/www.ldc.upenn.edu/files/etb-supplementary-guidelines-2009-addendum.pdf
// http://clear.colorado.edu/compsem/documents/treebank_guidelines.pdf
HYPH // Hyphen in split compounds
AFX // affix
ADD // url or email addy
NFP // superfluous (non final) puncutation
GW // Goes WIth
XX // deidentified data (aka giberish)
MAXTAG
)
// POSTagShortcut is a shortcut function to help the POSTagger shortcircuit some decisions about what the tag is
func POSTagShortcut(l Lexeme) (POSTag, bool) {
switch l.LexemeType {
case Number:
return CD, true
case Punctuation:
switch l.Value {
case ",":
return COMMA, true
case ".":
return FULLSTOP, true
case "``":
return OPENQUOTE, true
case "''":
return CLOSEQUOTE, true
case ":":
return COLON, true
case "#":
return HASHSIGN, true
case "(":
return LEFTBRACE, true
case ")":
return RIGHTBRACE, true
default:
return X, false
}
case Symbol:
return SYM, true
case URI:
return ADD, true
case Date:
return CD, true
case Time:
return CD, true
case EOF:
return X, true
}
return X, false
}
// sets
var Adjectives = []POSTag{JJ, JJR, JJS}
var Nouns = []POSTag{NN, NNP, NNS, NNPS}
var ProperNouns = []POSTag{NNP, NNPS}
var Verbs = []POSTag{VB, VBD, VBG, VBN, VBP, VBZ}
var Adverbs = []POSTag{RB, RBR, RBS}
var Determiners = []POSTag{DT, PDT}
var Interrogatives = []POSTag{WDT, WP, PWP, WRB}
var Numbers = []POSTag{CD}
var Symbols = []POSTag{SYM, FULLSTOP, COMMA, OPENQUOTE, COLON, DOLLAR, HASHSIGN, LEFTBRACE, RIGHTBRACE, HYPH, NFP}
// IsIN returns true if the POSTag is a subordinating conjunction.
// The reason why this exists is because in the stanford tag, IN is the POSTag
// while in the universal dependencies, it's the SCONJ POSTag
func IsIN(x POSTag) bool { return x == IN }