-
Notifications
You must be signed in to change notification settings - Fork 1
/
rank.py
108 lines (72 loc) · 2.66 KB
/
rank.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! usr/bin/env python3
"""
Takes the parts of speech generated for a word and RETURNs a ranking
"""
import re
import flatten
def rank(pos_list):
value = 0
pos_list = flatten.flatten(pos_list) # turns the list into a string
most_likely = ''
less_likely = []
for item in pos_list:
item_string = str(item)
item_string = item_string.upper()
# ___________________________________ Sure Things
if re.search('5', item_string):
value = 5
most_likely = item_string
break
if 'PRP' in item_string:
value = 5
most_likely = item_string
if 'NUM' in item_string:
value = 5
most_likely = item_string
if 'CNJ' in item_string:
value = 5
most_likely = item_string
if 'PRN' in item_string:
value = 5
most_likely = item_string
if 'pron' in item_string:
value = 5
most_likely = item_string
# ___________________________________ Likely Things
if value < 5:
if re.search('4', item_string):
value = 4
less_likely.append(item_string)
if re.search('N (m|f|n)', item_string):
value = 4
less_likely.append(item_string)
if re.search('N (M|F|N)', item_string):
value = 4
less_likely.append(item_string)
if re.search('m|n|f', item_string):
value = 4
less_likely.append(item_string)
if re.search('ppl|PPL', item_string):
value = 4
less_likely.append(item_string)
if re.search('V wk', item_string):
value = 4
less_likely.append(item_string)
if re.search('wk', item_string):
value = 4
less_likely.append(item_string)
if re.search('str', item_string):
value = 4
less_likely.append(item_string)
if re.search('irr', item_string):
value = 4
less_likely.append(item_string)
if re.search('3', item_string) and not re.search('4', item_string):
value = 3
less_likely.append(item_string)
# ________________________________________ Possible
# send to syntax.py to get nearby words
likely = (most_likely, less_likely)
return value, likely
# TODO: return best guess in first element, then all other guesses, ranked, in second element
# these ranks are had by COntrol, and written up in "start_here.py"