Commit 094a0f2f0dd6441064cfbaebcfb6ce935a4a5c3f
1 parent
d5a75fe6
Fixes for unknown heads.
Showing
1 changed file
with
10 additions
and
7 deletions
corneferencer/resolvers/features.py
... | ... | @@ -71,7 +71,9 @@ def sentence_vec(mention): |
71 | 71 | |
72 | 72 | def mention_type(mention): |
73 | 73 | type_vec = [0] * 4 |
74 | - if mention.head['ctag'] in constants.NOUN_TAGS: | |
74 | + if mention.head is None: | |
75 | + type_vec[3] = 1 | |
76 | + elif mention.head['ctag'] in constants.NOUN_TAGS: | |
75 | 77 | type_vec[0] = 1 |
76 | 78 | elif mention.head['ctag'] in constants.PPRON_TAGS: |
77 | 79 | type_vec[1] = 1 |
... | ... | @@ -145,7 +147,8 @@ def ante_contains_rarest_from_ana(ante, ana): |
145 | 147 | |
146 | 148 | def agreement(ante, ana, tag_name): |
147 | 149 | agr_vec = [0] * 3 |
148 | - if ante.head[tag_name] == 'unk' or ana.head[tag_name] == 'unk': | |
150 | + if (ante.head[tag_name] == 'unk' or ana.head[tag_name] == 'unk' | |
151 | + or ante.head is None or ana.head is None): | |
149 | 152 | agr_vec[2] = 1 |
150 | 153 | elif ante.head[tag_name] == ana.head[tag_name]: |
151 | 154 | agr_vec[0] = 1 |
... | ... | @@ -158,8 +161,8 @@ def is_acronym(ante, ana): |
158 | 161 | if ana.text.upper() == ana.text: |
159 | 162 | return check_one_way_acronym(ana.text, ante.text) |
160 | 163 | if ante.text.upper() == ante.text: |
161 | - return check_one_way_acronym(ante.text, ana.text); | |
162 | - return 0; | |
164 | + return check_one_way_acronym(ante.text, ana.text) | |
165 | + return 0 | |
163 | 166 | |
164 | 167 | |
165 | 168 | def same_sentence(ante, ana): |
... | ... | @@ -232,7 +235,7 @@ def check_one_way_acronym(acronym, expression): |
232 | 235 | for expr2 in expr1.split(): |
233 | 236 | expr2 = expr2.strip() |
234 | 237 | if expr2: |
235 | - initials += unicode(expr2[0]).upper() | |
238 | + initials += expr2[0].upper() | |
236 | 239 | if acronym == initials: |
237 | - return 1; | |
238 | - return 0; | |
240 | + return 1 | |
241 | + return 0 | |
... | ... |