-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_features_RNC.py
87 lines (76 loc) · 1.63 KB
/
get_features_RNC.py
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
# coding: utf-8
def get_features(gr):
features = []
''' aspect '''
if 'несов' in gr:
aspect = 'ipf'
elif 'сов' in gr:
aspect = 'pf'
else:
aspect = None
features.append(aspect)
''' tense '''
if 'непрош' in gr:
tense = 'praes'
elif 'прош' in gr:
tense = 'praet'
else:
tense = None
features.append(tense)
''' person '''
if '1-л' in gr:
pers = '1'
elif '2-л' in gr:
pers = '2'
elif '3-л' in gr:
pers = '3'
else:
pers = None
features.append(pers)
''' number '''
if 'ед' in gr:
num = 'sg'
elif 'мн' in gr:
num = 'pl'
else:
num = None
features.append(num)
''' transitivity '''
if 'пе' in gr:
trans = 'tran'
elif 'нп' in gr:
trans = 'intr'
else:
trans = None
features.append(trans)
''' voice '''
if 'действ' in gr:
voice = 'act'
elif 'страд' in gr:
voice = 'pass'
elif 'мед' in gr:
voice = 'med'
else:
voice = None
features.append(voice)
''' form '''
if 'инф' in gr:
form = 'inf'
elif 'прич' in gr:
form = 'partcp'
elif 'деепр' in gr:
form = 'ger'
else:
form = 'fin'
features.append(form)
''' mood '''
if 'изъяв' in gr:
mood = 'indic'
elif 'пов' in gr:
mood = 'imper'
else:
mood = None
features.append(mood)
# to avoid empty cells because of NoneType
features = [str(f) for f in features]
return features