Commit cdcb85d416d936b45df480ba545d31ad48161110
1 parent
a898d2a3
Head related bugfixes.
Showing
1 changed file
with
22 additions
and
2 deletions
corneferencer/resolvers/features.py
... | ... | @@ -87,6 +87,8 @@ def mention_type(mention): |
87 | 87 | |
88 | 88 | |
89 | 89 | def is_first_second_person(mention): |
90 | + if mention.head is None: | |
91 | + return 0 | |
90 | 92 | if mention.head['person'] in constants.FIRST_SECOND_PERSON: |
91 | 93 | return 1 |
92 | 94 | return 0 |
... | ... | @@ -99,12 +101,16 @@ def is_demonstrative(mention): |
99 | 101 | |
100 | 102 | |
101 | 103 | def is_demonstrative_nominal(mention): |
104 | + if mention.head is None: | |
105 | + return 0 | |
102 | 106 | if is_demonstrative(mention) and mention.head['ctag'] in constants.NOUN_TAGS: |
103 | 107 | return 1 |
104 | 108 | return 0 |
105 | 109 | |
106 | 110 | |
107 | 111 | def is_demonstrative_pronoun(mention): |
112 | + if mention.head is None: | |
113 | + return 0 | |
108 | 114 | if (is_demonstrative(mention) and |
109 | 115 | (mention.head['ctag'] in constants.PPRON_TAGS or mention.head['ctag'] in constants.ZERO_TAGS)): |
110 | 116 | return 1 |
... | ... | @@ -112,6 +118,8 @@ def is_demonstrative_pronoun(mention): |
112 | 118 | |
113 | 119 | |
114 | 120 | def is_refl_pronoun(mention): |
121 | + if mention.head is None: | |
122 | + return 0 | |
115 | 123 | if mention.head['ctag'] in constants.SIEBIE_TAGS: |
116 | 124 | return 1 |
117 | 125 | return 0 |
... | ... | @@ -124,6 +132,8 @@ def is_first_in_sentence(mention): |
124 | 132 | |
125 | 133 | |
126 | 134 | def is_zero_or_pronoun(mention): |
135 | + if mention.head is None: | |
136 | + return 0 | |
127 | 137 | if mention.head['ctag'] in constants.PPRON_TAGS or mention.head['ctag'] in constants.ZERO_TAGS: |
128 | 138 | return 1 |
129 | 139 | return 0 |
... | ... | @@ -150,7 +160,7 @@ def contains_letter(mention): |
150 | 160 | |
151 | 161 | |
152 | 162 | def post_modified(mention): |
153 | - if mention.head['orth'] != mention.words[-1]['orth']: | |
163 | + if mention.head_orth != mention.words[-1]['orth']: | |
154 | 164 | return 1 |
155 | 165 | return 0 |
156 | 166 | |
... | ... | @@ -268,7 +278,8 @@ def same_paragraph(ante, ana): |
268 | 278 | |
269 | 279 | def flat_gender_agreement(ante, ana): |
270 | 280 | agr_vec = [0] * 3 |
271 | - if ante.head['gender'] == 'unk' or ana.head['gender'] == 'unk': | |
281 | + if (ante.head is None or ana.head is None or | |
282 | + ante.head['gender'] == 'unk' or ana.head['gender'] == 'unk'): | |
272 | 283 | agr_vec[2] = 1 |
273 | 284 | elif (ante.head['gender'] == ana.head['gender'] or |
274 | 285 | (ante.head['gender'] in constants.MASCULINE_TAGS and ana.head['gender'] in constants.MASCULINE_TAGS)): |
... | ... | @@ -314,6 +325,9 @@ def head_string_kernel(ante, ana): |
314 | 325 | |
315 | 326 | def wordnet_synonyms(ante, ana): |
316 | 327 | ante_synonyms = set() |
328 | + if ante.head is None or ana.head is None: | |
329 | + return 0 | |
330 | + | |
317 | 331 | if ante.head['base'] in conf.LEMMA2SYNONYMS: |
318 | 332 | ante_synonyms = conf.LEMMA2SYNONYMS[ante.head['base']] |
319 | 333 | |
... | ... | @@ -327,6 +341,9 @@ def wordnet_synonyms(ante, ana): |
327 | 341 | |
328 | 342 | |
329 | 343 | def wordnet_ana_is_hypernym(ante, ana): |
344 | + if ante.head is None or ana.head is None: | |
345 | + return 0 | |
346 | + | |
330 | 347 | ante_hypernyms = set() |
331 | 348 | if ante.head['base'] in conf.LEMMA2HYPERNYMS: |
332 | 349 | ante_hypernyms = conf.LEMMA2HYPERNYMS[ante.head['base']] |
... | ... | @@ -344,6 +361,9 @@ def wordnet_ana_is_hypernym(ante, ana): |
344 | 361 | |
345 | 362 | |
346 | 363 | def wordnet_ante_is_hypernym(ante, ana): |
364 | + if ante.head is None or ana.head is None: | |
365 | + return 0 | |
366 | + | |
347 | 367 | ana_hypernyms = set() |
348 | 368 | if ana.head['base'] in conf.LEMMA2HYPERNYMS: |
349 | 369 | ana_hypernyms = conf.LEMMA2HYPERNYMS[ana.head['base']] |
... | ... |