@@ -25,121 +25,146 @@ def __init__(self, flavio=False, **kwargs):
25
25
self .flavio = flavio
26
26
27
27
def process_node (self , node ):
28
+ rf = []
29
+ af = {}
28
30
# NOUNS ################################################################
29
31
if node .upos == 'NOUN' :
30
- rf = ['Gender' , 'Number' , 'Case' ]
32
+ if not node .feats ['Abbr' ] == 'Yes' :
33
+ rf = ['Gender' , 'Number' , 'Case' ]
31
34
af = {
32
35
'Gender' : ['Masc' , 'Fem' , 'Neut' ],
33
36
'Number' : ['Sing' , 'Plur' ],
34
37
'Case' : ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ],
38
+ 'Degree' : ['Dim' ],
39
+ 'Abbr' : ['Yes' ],
35
40
'Foreign' : ['Yes' ]}
36
41
if self .flavio :
37
- rf . append ( ' InflClass' )
38
- af ['InflClass' ] = ['IndEurA' , 'IndEurO' , 'IndEurX' ]
42
+ # Flavio added InflClass but not everywhere, so it is not required.
43
+ af ['InflClass' ] = ['IndEurA' , 'IndEurE' , 'IndEurI' , ' IndEurO' , 'IndEurU ' , 'IndEurX' ]
39
44
self .check_required_features (node , rf )
40
45
self .check_allowed_features (node , af )
41
46
# PROPER NOUNS #########################################################
42
47
elif node .upos == 'PROPN' :
43
- self .check_required_features (node , ['Gender' , 'Number' , 'Case' ])
44
- self .check_allowed_features (node , {
48
+ if not node .feats ['Abbr' ] == 'Yes' :
49
+ rf = ['Gender' , 'Number' , 'Case' ]
50
+ af = {
45
51
'Gender' : ['Masc' , 'Fem' , 'Neut' ],
46
52
'Number' : ['Sing' , 'Plur' ],
47
53
'Case' : ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ],
48
54
'NameType' : ['Giv' , 'Sur' , 'Geo' ],
49
- 'Foreign' : ['Yes' ]})
55
+ 'Abbr' : ['Yes' ],
56
+ 'Foreign' : ['Yes' ]}
57
+ if self .flavio :
58
+ # Flavio added InflClass but not everywhere, so it is not required.
59
+ af ['InflClass' ] = ['IndEurA' , 'IndEurE' , 'IndEurI' , 'IndEurO' , 'IndEurU' , 'IndEurX' ]
60
+ af ['Proper' ] = ['Yes' ]
61
+ self .check_required_features (node , rf )
62
+ self .check_allowed_features (node , af )
50
63
# ADJECTIVES ###########################################################
51
64
elif node .upos == 'ADJ' :
52
- rf = ['Gender' , 'Number' , 'Case' , 'Degree' ]
65
+ if not node .feats ['Abbr' ] == 'Yes' :
66
+ rf = ['Gender' , 'Number' , 'Case' , 'Degree' ]
53
67
af = {
68
+ 'NumType' : ['Ord' , 'Dist' ],
54
69
'Gender' : ['Masc' , 'Fem' , 'Neut' ],
55
70
'Number' : ['Sing' , 'Plur' ],
56
71
'Case' : ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ],
57
72
'Degree' : ['Pos' , 'Cmp' , 'Sup' , 'Abs' ],
73
+ 'Abbr' : ['Yes' ],
58
74
'Foreign' : ['Yes' ]}
59
75
if self .flavio :
60
76
# Flavio does not use Degree=Pos, hence Degree is not required.
61
77
rf = [f for f in rf if f != 'Degree' ]
62
- rf .append ('InflClass' )
63
- af ['InflClass' ] = ['IndEurA' , 'IndEurO' , 'IndEurX' ]
78
+ # Flavio added InflClass but not everywhere, so it is not required.
79
+ af ['InflClass' ] = ['IndEurA' , 'IndEurE' , 'IndEurI' , 'IndEurO' , 'IndEurU' , 'IndEurX' ]
80
+ af ['Compound' ] = ['Yes' ]
81
+ af ['Proper' ] = ['Yes' ]
64
82
self .check_required_features (node , rf )
65
83
self .check_allowed_features (node , af )
66
84
# PRONOUNS #############################################################
67
85
elif node .upos == 'PRON' :
68
- self .check_required_features (node , ['PronType' ])
86
+ rf = ['PronType' , 'Case' ]
87
+ af = {
88
+ 'PronType' : ['Prs' , 'Rel' , 'Ind' ],
89
+ 'Case' : ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ]
90
+ }
69
91
if node .feats ['PronType' ] == 'Prs' :
70
- if node .feats ['Reflex' ] == 'Yes' :
71
- self .check_required_features (node , ['PronType' , 'Reflex' , 'Case' ])
72
- self .check_allowed_features (node , {
73
- 'PronType' : ['Prs' ],
74
- 'Reflex' : ['Yes' ],
75
- 'Case' : ['Gen' , 'Dat' , 'Acc' , 'Loc' , 'Abl' ]
76
- })
77
- else : # not reflexive
78
- if node .feats ['Person' ] == '3' : # on, ona, ono, oni, ony
79
- self .check_required_features (node , ['PronType' , 'Person' , 'Gender' , 'Number' , 'Case' ])
80
- self .check_allowed_features (node , {
81
- 'PronType' : ['Prs' ],
82
- 'Person' : ['3' ],
83
- 'Gender' : ['Masc' , 'Fem' , 'Neut' ],
84
- 'Number' : ['Sing' , 'Plur' ],
85
- 'Case' : ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ]
86
- })
87
- else : # 1st and 2nd person do not have gender: já, ty
88
- self .check_required_features (node , ['PronType' , 'Person' , 'Number' , 'Case' ])
89
- self .check_allowed_features (node , {
90
- 'PronType' : ['Prs' ],
91
- 'Person' : ['1' , '2' ],
92
- 'Number' : ['Sing' , 'Plur' ],
93
- 'Case' : ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ]
94
- })
92
+ af ['Reflex' ] = ['Yes' ]
93
+ if node .feats ['Reflex' ] == 'Yes' : # seipsum, se
94
+ # seipsum has gender and number but se does not, so it is not required
95
+ af ['Gender' ] = ['Masc' ]
96
+ af ['Number' ] = ['Sing' ]
97
+ af ['Person' ] = ['3' ]
98
+ af ['Case' ] = ['Gen' , 'Dat' , 'Acc' , 'Loc' , 'Abl' ]
99
+ else : # not reflexive: ego, tu, is, nos
100
+ rf .extend (['Person' , 'Number' ])
101
+ af ['Person' ] = ['1' , '2' , '3' ]
102
+ af ['Number' ] = ['Sing' , 'Plur' ]
103
+ # 1st and 2nd person do not have gender
104
+ if node .feats ['Person' ] == '3' : # is, id
105
+ rf .append ('Gender' )
106
+ af ['Gender' ] = ['Masc' , 'Fem' , 'Neut' ]
107
+ elif re .match (r'^(Rel|Ind)$' , node .feats ['PronType' ]):
108
+ rf .extend (['Gender' , 'Number' ])
109
+ af ['Gender' ] = ['Masc' , 'Fem' , 'Neut' ]
110
+ af ['Number' ] = ['Sing' , 'Plur' ]
111
+ if self .flavio :
112
+ # Flavio added InflClass but not everywhere, so it is not required.
113
+ af ['InflClass' ] = ['LatAnom' , 'LatPron' ]
114
+ self .check_required_features (node , rf )
115
+ self .check_allowed_features (node , af )
95
116
# DETERMINERS ##########################################################
96
117
elif node .upos == 'DET' :
97
- if node .feats ['Poss' ] == 'Yes' : # 'můj', 'tvůj', 'svůj'
98
- self .check_required_features (node , ['PronType' , 'Poss' , 'Person' , 'Gender' , 'Number' , 'Case' ])
99
- self .check_allowed_features (node , {
100
- 'PronType' : ['Prs' ],
101
- 'Poss' : ['Yes' ],
102
- 'Person' : ['1' , '2' , '3' ],
103
- 'Gender' : ['Masc' , 'Fem' , 'Neut' ],
104
- 'Number' : ['Sing' , 'Plur' ],
105
- 'Case' : ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ]
106
- })
118
+ rf = ['PronType' , 'Gender' , 'Number' , 'Case' ]
119
+ af = {
120
+ 'Gender' : ['Masc' , 'Fem' , 'Neut' ],
121
+ 'Number' : ['Sing' , 'Plur' ],
122
+ 'Case' : ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ]}
123
+ if node .feats ['Poss' ] == 'Yes' : # 'meus', 'tuus', 'suus', 'noster'
124
+ rf .extend (['Poss' , 'Person[psor]' ])
125
+ af ['PronType' ] = ['Prs' ]
126
+ af ['Poss' ] = 'Yes'
127
+ af ['Person[psor]' ] = ['1' , '2' , '3' ]
128
+ af ['Reflex' ] = ['Yes' ]
129
+ # The possessor's number is distinguished in the first and second person (meus vs. noster) but not in the third person (suus).
130
+ if node .feats ['Person[psor]' ] != '3' :
131
+ rf .append ('Number[psor]' )
132
+ af ['Number[psor]' ] = ['Sing' , 'Plur' ]
107
133
else :
108
- rf = ['PronType' , 'Gender' , 'Number' , 'Case' ]
109
- af = {
110
- 'PronType' : ['Dem' , 'Int' , 'Rel' , 'Ind' , 'Neg' , 'Tot' , 'Emp' ],
111
- 'Gender' : ['Masc' , 'Fem' , 'Neut' ],
112
- 'Number' : ['Sing' , 'Plur' ],
113
- 'Case' : ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ]}
114
- if self .flavio :
115
- rf .append ('InflClass' )
116
- af ['PronType' ].append ('Con' )
117
- af ['InflClass' ] = ['LatPron' ]
118
- af ['Form' ] = ['Emp' ]
119
- self .check_required_features (node , rf )
120
- self .check_allowed_features (node , af )
134
+ af ['PronType' ] = ['Dem' , 'Rel' , 'Ind' , 'Tot' , 'Con' ]
135
+ if self .flavio :
136
+ # Flavio added InflClass but not everywhere, so it is not required.
137
+ af ['InflClass' ] = ['IndEurA' , 'IndEurI' , 'IndEurO' , 'LatPron' ]
138
+ af ['Form' ] = ['Emp' ]
139
+ self .check_required_features (node , rf )
140
+ self .check_allowed_features (node , af )
121
141
# NUMERALS #############################################################
122
142
elif node .upos == 'NUM' :
123
- self .check_required_features (node , ['NumType' , 'NumForm' ])
143
+ rf = ['NumType' , 'NumForm' ]
144
+ af = {
145
+ 'NumType' : ['Card' ],
146
+ 'NumForm' : ['Word' , 'Roman' , 'Digit' ]
147
+ }
124
148
# Arabic digits and Roman numerals do not have inflection features.
125
- if re .match (r'^(Digit|Roman)$' , node .feats ['NumForm' ]):
126
- self .check_allowed_features (node , {
127
- 'NumType' : ['Card' ],
128
- 'NumForm' : ['Digit' , 'Roman' ]
129
- })
130
- else :
131
- self .check_required_features (node , ['NumType' , 'NumForm' ])
132
- self .check_allowed_features (node , {
133
- 'NumType' : ['Card' ],
134
- 'NumForm' : ['Word' ]
135
- })
149
+ if not re .match (r'^(Digit|Roman)$' , node .feats ['NumForm' ]):
150
+ af ['Gender' ] = ['Masc' , 'Fem' , 'Neut' ]
151
+ af ['Number' ] = ['Sing' , 'Plur' ]
152
+ af ['Case' ] = ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ]
153
+ if self .flavio :
154
+ # Flavio added InflClass but not everywhere, so it is not required.
155
+ af ['InflClass' ] = ['IndEurA' , 'IndEurI' , 'IndEurO' , 'LatPron' ]
156
+ self .check_required_features (node , rf )
157
+ self .check_allowed_features (node , af )
136
158
# VERBS AND AUXILIARIES ################################################
137
159
elif re .match (r'^(VERB|AUX)$' , node .upos ):
138
- rf = ['Aspect' , ' VerbForm' ]
160
+ rf = ['VerbForm' ]
139
161
af = {
140
- 'Aspect' : ['Imp' , 'Perf' , 'Prosp' ],
141
162
'VerbForm' : ['Inf' , 'Fin' , 'Part' , 'Vnoun' ],
142
163
'Polarity' : ['Pos' , 'Neg' ]}
164
+ # Main verbs have aspect but auxiliaries don't.
165
+ if node .upos == 'VERB' :
166
+ rf .append ('Aspect' )
167
+ af ['Aspect' ] = ['Imp' , 'Perf' , 'Prosp' ]
143
168
if node .feats ['VerbForm' ] == 'Fin' :
144
169
rf .extend (['Mood' , 'Person' , 'Number' ])
145
170
af ['Mood' ] = ['Ind' , 'Sub' , 'Imp' ]
@@ -150,40 +175,48 @@ def process_node(self, node):
150
175
af ['Voice' ] = ['Act' , 'Pass' ]
151
176
af ['Tense' ] = ['Past' , 'Imp' , 'Pres' , 'Fut' ]
152
177
elif node .feats ['VerbForm' ] == 'Part' :
153
- rf .extend (['Tense' , 'Gender' , 'Number' , 'Voice' ])
178
+ rf .extend (['Tense' , 'Gender' , 'Number' , 'Voice' , 'Case' ])
154
179
af ['Tense' ] = ['Past' ]
155
- af ['Voice' ] = ['Act' ]
180
+ af ['Voice' ] = ['Act' , 'Pass' ]
156
181
af ['Number' ] = ['Sing' , 'Plur' ]
157
182
af ['Gender' ] = ['Masc' , 'Fem' , 'Neut' ]
158
- else : # verbal noun
183
+ af ['Case' ] = ['Nom' , 'Gen' , 'Dat' , 'Acc' , 'Voc' , 'Loc' , 'Abl' ]
184
+ af ['Degree' ] = ['Abs' ]
185
+ elif node .feats ['VerbForm' ] == 'Vnoun' :
159
186
rf .extend (['Tense' , 'Voice' ])
160
187
af ['Tense' ] = ['Past' , 'Pres' ]
161
- af ['Voice' ] = ['Act' ]
188
+ af ['Voice' ] = ['Act' , 'Pass' ]
162
189
af ['Gender' ] = ['Masc' , 'Fem' , 'Neut' ]
190
+ # else: nothing to be added form VerbForm=Inf
163
191
if self .flavio :
164
192
# Flavio has killed Tense in his treebanks.
165
193
rf = [f for f in rf if f != 'Tense' ]
166
194
# Flavio added InflClass but not everywhere, so it is not required.
167
195
af ['InflClass' ] = ['LatA' , 'LatAnom' , 'LatE' , 'LatI2' , 'LatX' ]
196
+ if node .feats ['VerbForm' ] == 'Part' :
197
+ af ['InflClass[nominal]' ] = ['IndEurA' , 'IndEurI' , 'IndEurO' ]
168
198
self .check_required_features (node , rf )
169
199
self .check_allowed_features (node , af )
170
200
# ADVERBS ##############################################################
171
201
elif node .upos == 'ADV' :
172
- if node .feats ['PronType' ] != '' :
173
- # Pronominal adverbs are neither compared nor negated.
174
- self .check_allowed_features (node , {
175
- 'PronType' : ['Dem' , 'Int' , 'Rel' , 'Ind' , 'Neg' , 'Tot' ],
176
- 'AdvType' : ['Loc' ]
177
- })
178
- else :
179
- # The remaining adverbs are neither pronominal, nor compared or
180
- # negated.
181
- self .check_allowed_features (node , {})
202
+ af = {
203
+ 'AdvType' : ['Loc' , 'Tim' ],
204
+ 'PronType' : ['Dem' , 'Int' , 'Rel' , 'Ind' , 'Neg' , 'Tot' , 'Con' ],
205
+ 'Degree' : ['Pos' , 'Cmp' , 'Sup' , 'Abs' ]
206
+ }
207
+ if self .flavio :
208
+ af ['Compound' ] = 'Yes'
209
+ af ['Form' ] = 'Emp'
210
+ self .check_allowed_features (node , af )
182
211
# PARTICLES ############################################################
183
212
elif node .upos == 'PART' :
184
- self .check_allowed_features (node , {
213
+ af = {
214
+ 'PartType' : ['Int' ],
185
215
'Polarity' : ['Neg' ]
186
- })
216
+ }
217
+ if self .flavio :
218
+ af ['Form' ] = 'Emp'
219
+ self .check_allowed_features (node , af )
187
220
# THE REST: NO FEATURES ################################################
188
221
else :
189
222
self .check_allowed_features (node , {})
0 commit comments