File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -121,19 +121,21 @@ def pprint_coreference_document(doc: CoreferenceDocument):
121121
122122 for token_i , token in enumerate (doc .tokens ):
123123
124- related_chains = [
124+ related_mentions = [
125125 (chain_i , start_i , end_i )
126126 for chain_i , start_i , end_i in mentions
127127 if start_i == token_i or end_i - 1 == token_i
128128 ]
129+ # sort to have outermost mentions first
130+ related_mentions = sorted (related_mentions , key = lambda c : c [1 ] - c [2 ])
129131
130- for chain_i , start_i , _ in related_chains :
132+ for chain_i , start_i , _ in related_mentions :
131133 if token_i == start_i :
132134 out .append (f"[red]({ chain_i } " )
133135
134136 out .append (token )
135137
136- for chain_i , _ , end_i in related_chains :
138+ for chain_i , _ , end_i in related_mentions :
137139 if token_i == end_i - 1 :
138140 out .append (f")[/red]" )
139141
You can’t perform that action at this time.
0 commit comments