@@ -129,7 +129,7 @@ def process_documents(docs, augment=False):
129129 if sentence_text [span [1 ]] == "_" and span [1 ] == span [2 ]:
130130 is_zero .append ([span [0 ], True ])
131131 zero = True
132- # oo! thaht 's a zero coref, we should merge it forwards
132+ # oo! that 's a zero coref, we should merge it forwards
133133 # i.e. we pick the next word as the head!
134134 span = [span [0 ], span [1 ]+ 1 , span [2 ]+ 1 ]
135135 # crap! there's two zeros right next to each other
@@ -163,7 +163,7 @@ def process_documents(docs, augment=False):
163163 # words from 0, so we have to subtract 1 from the stanza heads
164164 #print(span, candidate_head, parsed_sentence.words[candidate_head].head - 1)
165165 # treat the head of the phrase as the first word that has a head outside the phrase
166- if parsed_sentence .all_words [candidate_head ].head and (
166+ if ( parsed_sentence .all_words [candidate_head ].head is not None ) and (
167167 parsed_sentence .all_words [candidate_head ].head - 1 < span [1 ] or
168168 parsed_sentence .all_words [candidate_head ].head - 1 > span [2 ]
169169 ):
@@ -205,7 +205,7 @@ def process_documents(docs, augment=False):
205205 [(old_to_new [start ], old_to_new [end - 1 ] + 1 ) for start , end in cluster ]
206206 for cluster in span_clusters
207207 ]
208- except :
208+ except ( KeyError , TypeError ) as _ : # two errors, either end-1 = -1, or start/end is None
209209 warnings .warn ("Somehow, we are still coreffering to a zero. This is likely due to multiple zeros on top of each other. We are giving up." )
210210 continue
211211 word_clusters = [
0 commit comments