Spaces:
Runtime error
Runtime error
Commit
·
87e7bb0
1
Parent(s):
b949fc4
Update comparativesIdentification.py
Browse files
comparativesIdentification.py
CHANGED
@@ -51,8 +51,8 @@ def find_comptives_straight_patterns(sentence):
|
|
51 |
prev_token = token.nbor(-1)
|
52 |
|
53 |
if prev_token.pos_ == "NOUN":
|
54 |
-
comparatives.append({'comparative': ["equal to", "="]})
|
55 |
-
|
56 |
|
57 |
# find mentions of "more"/"less" followed by "than"
|
58 |
elif token.text.lower() in ["more", "less"]:
|
@@ -63,10 +63,12 @@ def find_comptives_straight_patterns(sentence):
|
|
63 |
prev_token = token.nbor(-1)
|
64 |
|
65 |
if token.text.lower() == 'more':
|
66 |
-
comparatives.append({'comparative': [token.text + " " + next_token.text, '>']})
|
67 |
-
|
68 |
-
comparatives.append({'comparative': [token.text + " " + next_token.text, '<']})
|
69 |
|
|
|
|
|
|
|
70 |
|
71 |
# find mentions of comparative adjectives or comparative adverbs followed by "than"
|
72 |
elif token.tag_ == "JJR" or token.tag_ == "RBR":
|
@@ -93,7 +95,8 @@ def find_comptives_straight_patterns(sentence):
|
|
93 |
|
94 |
if token.text.lower() in bigger_rel_words:
|
95 |
flag_bigger = 1
|
96 |
-
comparatives.append({'comparative': [token.text + " " + next_token.text, '>']})
|
|
|
97 |
|
98 |
# if no synonym of bigger was found, check for smaller synsets
|
99 |
if not flag_bigger:
|
@@ -111,11 +114,14 @@ def find_comptives_straight_patterns(sentence):
|
|
111 |
|
112 |
if token.text.lower() in smaller_rel_words:
|
113 |
flag_bigger = 0
|
114 |
-
comparatives.append({'comparative': [token.text + " " + next_token.text, '<']})
|
|
|
115 |
|
116 |
return comparatives
|
117 |
|
118 |
-
|
|
|
|
|
119 |
# helper functions for 'identify_pattern_bigger_smaller'
|
120 |
|
121 |
def identify_comparison(sentence):
|
|
|
51 |
prev_token = token.nbor(-1)
|
52 |
|
53 |
if prev_token.pos_ == "NOUN":
|
54 |
+
# comparatives.append({'comparative': ["equal to", "="]})
|
55 |
+
comparatives.append({'comparative': "="})
|
56 |
|
57 |
# find mentions of "more"/"less" followed by "than"
|
58 |
elif token.text.lower() in ["more", "less"]:
|
|
|
63 |
prev_token = token.nbor(-1)
|
64 |
|
65 |
if token.text.lower() == 'more':
|
66 |
+
# comparatives.append({'comparative': [token.text + " " + next_token.text, '>']})
|
67 |
+
comparatives.append({'comparative': '>'})
|
|
|
68 |
|
69 |
+
elif token.text.lower() == 'less':
|
70 |
+
# comparatives.append({'comparative': [token.text + " " + next_token.text, '<']})
|
71 |
+
comparatives.append({'comparative': '<'})
|
72 |
|
73 |
# find mentions of comparative adjectives or comparative adverbs followed by "than"
|
74 |
elif token.tag_ == "JJR" or token.tag_ == "RBR":
|
|
|
95 |
|
96 |
if token.text.lower() in bigger_rel_words:
|
97 |
flag_bigger = 1
|
98 |
+
# comparatives.append({'comparative': [token.text + " " + next_token.text, '>']})
|
99 |
+
comparatives.append({'comparative': '>'})
|
100 |
|
101 |
# if no synonym of bigger was found, check for smaller synsets
|
102 |
if not flag_bigger:
|
|
|
114 |
|
115 |
if token.text.lower() in smaller_rel_words:
|
116 |
flag_bigger = 0
|
117 |
+
# comparatives.append({'comparative': [token.text + " " + next_token.text, '<']})
|
118 |
+
comparatives.append({'comparative': '<'})
|
119 |
|
120 |
return comparatives
|
121 |
|
122 |
+
|
123 |
+
# helper functions for 'identify_pattern_bigger_smaller'
|
124 |
+
|
125 |
# helper functions for 'identify_pattern_bigger_smaller'
|
126 |
|
127 |
def identify_comparison(sentence):
|