Skip to content

Corefud.FixInterleaved may cause two mentions to have the same span #98

@dan-zeman

Description

@dan-zeman

Following https://github.com/ufal/corefUD/issues/24, it is not allowed for two entity mentions in one file to have the same span. The block corefud.FixInterleaved, while trying to fix other validation issues, occasionally causes two mentions to have the same span. It would be useful if the block checked whether it happens, issued a warning and/or removed one of the mentions. Alternatively, this could be done by a separate block that would be applied after this one. Note however that the two mentions may not belong to the same cluster, hence it may not be obvious what to remove.

An example from the training data of Czech PDT:

# sent_id = ln95045-071-p5s3
# text = Naštěstí je tentokrát pro českou armádu příhodná i doba: vojáci, alespoň ti z brigády rychlého nasazení, začínají kupodivu sami dávat přednost ostrému výcviku před kasárenskou nudou.
# orig_file_sentence ln95045_071#19
1	Naštěstí	naštěstí	ADV	Db-------------	_	2	advmod	2:advmod	_
2	je	být	VERB	VB-S---3P-AAI--	Aspect=Imp|Mood=Ind|Number=Sing|Person=3|Polarity=Pos|Tense=Pres|VerbForm=Fin|Voice=Act	0	root	0:root	_
3	tentokrát	tentokrát	ADV	Db-------------	PronType=Dem	2	advmod	2:advmod	_
4	pro	pro	ADP	RR--4----------	AdpType=Prep|Case=Acc	6	case	6:case	LId=pro-1
5	českou	český	ADJ	AAFS4----1A----	Case=Acc|Degree=Pos|Gender=Fem|Number=Sing|Polarity=Pos	6	amod	6:amod	ClusterId=ln95045071c6|MentionSpan=5|MentionHead=5|MentionText=českou|MentionMisc=gstype:spec
6	armádu	armáda	NOUN	NNFS4-----A----	Case=Acc|Gender=Fem|Number=Sing|Polarity=Pos	2	obl	2:obl:pro:acc	ClusterId=ln95045071c8|MentionSpan=4-6|MentionHead=6|MentionText=pro českou armádu|MentionMisc=gstype:spec
7	příhodná	příhodný	ADJ	AAFS1----1A----	Case=Nom|Degree=Pos|Gender=Fem|Number=Sing|Polarity=Pos	9	amod	9:amod	_
8	i	i	CCONJ	J^-------------	_	9	advmod:emph	9:advmod:emph	LId=i-1
9	doba	doba	NOUN	NNFS1-----A----	Case=Nom|Gender=Fem|Number=Sing|Polarity=Pos	2	nsubj	2:nsubj	SpaceAfter=No
10	:	:	PUNCT	Z:-------------	_	20	punct	20:punct	_
11	vojáci	voják	NOUN	NNMP1-----A----	Animacy=Anim|Case=Nom|Gender=Masc|Number=Plur|Polarity=Pos	20	nsubj	20:nsubj|23:nsubj	SpaceAfter=No|ClusterId=ln95045071c33|MentionSpan=11-13|MentionHead=11,12,13|MentionText=vojáci, alespoň|MentionMisc=gstype:spec
12	,	,	PUNCT	Z:-------------	_	14	punct	14:punct	ClusterId=ln95045071c35|MentionSpan=11-18|MentionHead=11|MentionText=vojáci, alespoň ti z brigády rychlého nasazení
13	alespoň	alespoň	ADV	Db-------------	_	14	advmod	14:advmod	LId=alespoň-1
14	ti	ten	DET	PDMP1----------	Animacy=Anim|Case=Nom|Gender=Masc|Number=Plur|PronType=Dem	11	det	11:det	ClusterId=ln95045071c33|MentionSpan=13-18|MentionHead=14|MentionText=alespoň ti z brigády rychlého nasazení|MentionMisc=gstype:spec
15	z	z	ADP	RR--2----------	AdpType=Prep|Case=Gen	16	case	16:case	LId=z-1
16	brigády	brigáda	NOUN	NNFS2-----A----	Case=Gen|Gender=Fem|Number=Sing|Polarity=Pos	14	nmod	14:nmod:z:gen	ClusterId=ln95045071c34|MentionSpan=15-18|MentionHead=16|MentionText=z brigády rychlého nasazení
17	rychlého	rychlý	ADJ	AANS2----1A----	Case=Gen|Degree=Pos|Gender=Neut|Number=Sing|Polarity=Pos	18	amod	18:amod	_
18	nasazení	nasazení	NOUN	NNNS2-----A----	Case=Gen|Gender=Neut|Number=Sing|Polarity=Pos	16	nmod	16:nmod:gen	SpaceAfter=No|LDeriv=nasadit
19	,	,	PUNCT	Z:-------------	_	14	punct	14:punct	_
20	začínají	začínat	VERB	VB-P---3P-AAI--	Aspect=Imp|Mood=Ind|Number=Plur|Person=3|Polarity=Pos|Tense=Pres|VerbForm=Fin|Voice=Act	2	conj	0:root|2:conj	_
21	kupodivu	kupodivu	ADV	Db-------------	_	20	advmod	20:advmod	LId=kupodivu-1
22	sami	sám	DET	PLMP1----------	Animacy=Anim|Case=Nom|Gender=Masc|Number=Plur|PronType=Emp	11	xcomp	11:xcomp	LGloss=(samotný)
22.1	_	#Cor	PRON	_	PronType=Prs	_	_	23:nsubj	Functor=ACT|ClusterId=ln95045071c35|MentionSpan=22.1|MentionHead=22.1|MentionText=_
23	dávat	dávat	VERB	Vf--------A-I--	Aspect=Imp|Polarity=Pos|VerbForm=Inf	20	xcomp	20:xcomp	LId=dávat-1|LDeriv=dát
23.1	_	#QCor	PRON	_	PronType=Prs	_	_	24:nmod	Functor=ACT|ClusterId=ln95045071c14|MentionSpan=23.1|MentionHead=23.1|MentionText=_|MentionMisc=gstype:spec
24	přednost	přednost	NOUN	NNFS4-----A----	Case=Acc|Gender=Fem|Number=Sing|Polarity=Pos	23	obj	23:obj	_
25	ostrému	ostrý	ADJ	AAIS3----1A----	Animacy=Inan|Case=Dat|Degree=Pos|Gender=Masc|Number=Sing|Polarity=Pos	26	amod	26:amod	_
26	výcviku	výcvik	NOUN	NNIS3-----A----	Animacy=Inan|Case=Dat|Gender=Masc|Number=Sing|Polarity=Pos	23	obl:arg	23:obl:arg:dat	ClusterId=ln95045071c14|MentionSpan=25-26|MentionHead=26|MentionText=ostrému výcviku|MentionMisc=gstype:spec
27	před	před	ADP	RR--7----------	AdpType=Prep|Case=Ins	29	case	29:case	LId=před-1
28	kasárenskou	kasárenský	ADJ	AAFS7----1A----	Case=Ins|Degree=Pos|Gender=Fem|Number=Sing|Polarity=Pos	29	amod	29:amod	_
29	nudou	nuda	NOUN	NNFS7-----A----	Case=Ins|Gender=Fem|Number=Sing|Polarity=Pos	23	obl:arg	23:obl:arg:před:ins	SpaceAfter=No
30	.	.	PUNCT	Z:-------------	_	2	punct	2:punct	_

The segment of interest is 11-18, vojáci, alespoň ti z brigády rychlého nasazení.

After running it through

udapy -s read.OldCorefUD corefud.FixInterleaved

we get:

# sent_id = ln95045-071-p5s3
# text = Naštěstí je tentokrát pro českou armádu příhodná i doba: vojáci, alespoň ti z brigády rychlého nasazení, začínají kupodivu sami dávat přednost ostrému výcviku před kasárenskou nudou.
# orig_file_sentence ln95045_071#19
1	Naštěstí	naštěstí	ADV	Db-------------	_	2	advmod	2:advmod	_
2	je	být	VERB	VB-S---3P-AAI--	Aspect=Imp|Mood=Ind|Number=Sing|Person=3|Polarity=Pos|Tense=Pres|VerbForm=Fin|Voice=Act	0	root	0:root	_
3	tentokrát	tentokrát	ADV	Db-------------	PronType=Dem	2	advmod	2:advmod	_
4	pro	pro	ADP	RR--4----------	AdpType=Prep|Case=Acc	6	case	6:case	Entity=(ln95045071c8--3-gstype:spec|LId=pro-1
5	českou	český	ADJ	AAFS4----1A----	Case=Acc|Degree=Pos|Gender=Fem|Number=Sing|Polarity=Pos	6	amod	6:amod	Entity=(ln95045071c6--1-gstype:spec)|MentionHead=5|MentionText=českou
6	armádu	armáda	NOUN	NNFS4-----A----	Case=Acc|Gender=Fem|Number=Sing|Polarity=Pos	2	obl	2:obl:pro:acc	Entity=ln95045071c8)|MentionHead=6|MentionText=pro českou armádu
7	příhodná	příhodný	ADJ	AAFS1----1A----	Case=Nom|Degree=Pos|Gender=Fem|Number=Sing|Polarity=Pos	9	amod	9:amod	_
8	i	i	CCONJ	J^-------------	_	9	advmod:emph	9:advmod:emph	LId=i-1
9	doba	doba	NOUN	NNFS1-----A----	Case=Nom|Gender=Fem|Number=Sing|Polarity=Pos	2	nsubj	2:nsubj	SpaceAfter=No
10	:	:	PUNCT	Z:-------------	_	20	punct	20:punct	_
11	vojáci	voják	NOUN	NNMP1-----A----	Animacy=Anim|Case=Nom|Gender=Masc|Number=Plur|Polarity=Pos	20	nsubj	20:nsubj|23:nsubj	Entity=(ln95045071c33--1-gstype:spec(ln95045071c35--2|MentionHead=11,12,13|MentionText=vojáci, alespoň|SpaceAfter=No
12	,	,	PUNCT	Z:-------------	_	14	punct	14:punct	MentionHead=11|MentionText=vojáci, alespoň ti z brigády rychlého nasazení
13	alespoň	alespoň	ADV	Db-------------	_	14	advmod	14:advmod	LId=alespoň-1
14	ti	ten	DET	PDMP1----------	Animacy=Anim|Case=Nom|Gender=Masc|Number=Plur|PronType=Dem	11	det	11:det	MentionHead=14|MentionText=alespoň ti z brigády rychlého nasazení
15	z	z	ADP	RR--2----------	AdpType=Prep|Case=Gen	16	case	16:case	Entity=(ln95045071c34--2|LId=z-1
16	brigády	brigáda	NOUN	NNFS2-----A----	Case=Gen|Gender=Fem|Number=Sing|Polarity=Pos	14	nmod	14:nmod:z:gen	MentionHead=16|MentionText=z brigády rychlého nasazení
17	rychlého	rychlý	ADJ	AANS2----1A----	Case=Gen|Degree=Pos|Gender=Neut|Number=Sing|Polarity=Pos	18	amod	18:amod	_
18	nasazení	nasazení	NOUN	NNNS2-----A----	Case=Gen|Gender=Neut|Number=Sing|Polarity=Pos	16	nmod	16:nmod:gen	Entity=ln95045071c34)ln95045071c35)ln95045071c33)|LDeriv=nasadit|SpaceAfter=No
19	,	,	PUNCT	Z:-------------	_	14	punct	14:punct	_
20	začínají	začínat	VERB	VB-P---3P-AAI--	Aspect=Imp|Mood=Ind|Number=Plur|Person=3|Polarity=Pos|Tense=Pres|VerbForm=Fin|Voice=Act	2	conj	0:root|2:conj	_
21	kupodivu	kupodivu	ADV	Db-------------	_	20	advmod	20:advmod	LId=kupodivu-1
22	sami	sám	DET	PLMP1----------	Animacy=Anim|Case=Nom|Gender=Masc|Number=Plur|PronType=Emp	11	xcomp	11:xcomp	LGloss=(samotný)
22.1	_	#Cor	PRON	_	PronType=Prs	_	_	23:nsubj	Entity=(ln95045071c35--1)|Functor=ACT|MentionHead=22.1|MentionText=_
23	dávat	dávat	VERB	Vf--------A-I--	Aspect=Imp|Polarity=Pos|VerbForm=Inf	20	xcomp	20:xcomp	LId=dávat-1|LDeriv=dát
23.1	_	#QCor	PRON	_	PronType=Prs	_	_	24:nmod	Entity=(ln95045071c14--1-gstype:spec)|Functor=ACT|MentionHead=23.1|MentionText=_
24	přednost	přednost	NOUN	NNFS4-----A----	Case=Acc|Gender=Fem|Number=Sing|Polarity=Pos	23	obj	23:obj	_
25	ostrému	ostrý	ADJ	AAIS3----1A----	Animacy=Inan|Case=Dat|Degree=Pos|Gender=Masc|Number=Sing|Polarity=Pos	26	amod	26:amod	Entity=(ln95045071c14--2-gstype:spec
26	výcviku	výcvik	NOUN	NNIS3-----A----	Animacy=Inan|Case=Dat|Gender=Masc|Number=Sing|Polarity=Pos	23	obl:arg	23:obl:arg:dat	Entity=ln95045071c14)|MentionHead=26|MentionText=ostrému výcviku
27	před	před	ADP	RR--7----------	AdpType=Prep|Case=Ins	29	case	29:case	LId=před-1
28	kasárenskou	kasárenský	ADJ	AAFS7----1A----	Case=Ins|Degree=Pos|Gender=Fem|Number=Sing|Polarity=Pos	29	amod	29:amod	_
29	nudou	nuda	NOUN	NNFS7-----A----	Case=Ins|Gender=Fem|Number=Sing|Polarity=Pos	23	obl:arg	23:obl:arg:před:ins	SpaceAfter=No
30	.	.	PUNCT	Z:-------------	_	2	punct	2:punct	_

Mentions with cluster ids *c33 and *c35 now have identical spans. Without the FixInterleaved block, only c35 spans the whole phrase while c33 has two mentions (wrongly annotated, but anyway), sharing the word alespoň and otherwise covering the whole phrase. Interestingly, the mentions do not have the same head (so perhaps one should run another block to re-compute the heads after FixInterleaved?)

It should be noted that it is also wrong in this sentence that the mentions have different cluster ids. The likely reason is that in the original annotation, there is grammatical coreference between nodes 22.1 and 12 (head of coap), and there is another, independent coreference link between nodes 14 and 11. None of the clusters/entities appear elsewhere in the document, so they could be merged without problems. It may not be the case in general, but an algorithm can hardly find any better solution, so it should decide that the clusters are indeed the same, and pick one id and spread it to all mentions of both entities.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions