我想使用构建一个类型为Map<CorefChain, CoreEntityMention>
的查找映射
Map<Integer, Integer> mapping = document.annotation().get(CoreAnnotations.CorefMentionToEntityMentionMappingAnnotation.class);
其中CCD_ 2是CCD_。
我试图获得一组CorefChains和一个CoreEntityMents列表来构建这样的映射,但索引似乎不匹配。
Map<Integer, CorefChain> chains = document.corefChains();
List<CoreEntityMention> entities = document.entityMentions();
示例:
句子:
"ʿAmrān is a small city in western central Yemen. It is the capital of the 'Amran
Governorate, and was formerly in the Sana'a Governorate. It is located 52.9
kilometres by road northwest of the Yemeni capital of Sana'a. According to the
2004 census it had a population of 76,863, and an estimated population of
90,792 in 2012."
链:
{
1=CHAIN1-["a small city in western central Yemen" in sentence 1, "It" in sentence 2, "It" in sentence 3],
2=CHAIN2-["western central Yemen" in sentence 1],
4=CHAIN4-["the capital of the ` Amran Governorate" in sentence 2],
5=CHAIN5-["the ` Amran Governorate" in sentence 2],
6=CHAIN6-["the Sana'a Governorate" in sentence 2, "Sana'a" in sentence 3],
7=CHAIN7-["52.9" in sentence 3],
10=CHAIN10-["52.9 kilometres" in sentence 3],
11=CHAIN11-["road northwest of the Yemeni capital of Sana'a" in sentence 3],
12=CHAIN12-["the Yemeni capital of Sana'a" in sentence 3], 13=CHAIN13-["76,863" in sentence 4],
14=CHAIN14-["90,792" in sentence 4], 15=CHAIN15-["the 2004 census" in sentence 4, "it" in sentence 4],
17=CHAIN17-["a population of 76,863 , and an estimated population of 90,792 in 2012" in sentence 4],
18=CHAIN18-["a population of 76,863" in sentence 4],
19=CHAIN19-["an estimated population of 90,792 in 2012" in sentence 4],
20=CHAIN20-["2012" in sentence 4]
}
实体:
[Yemen, Sana'a Governorate, 52.9, Yemeni, Sana'a, 2004, 76,863, 90,792, 2012]
映射:
{16=8, 7=2, 8=4, 13=5, 14=6, 15=7}
需要明确的是,有两种类型的提及:
coref mentions
entity mentions
所有entity mentions
都应该是coref mentions
,但不是所有coref mentions
都是entity mentions
。
正如您所发现的,有一张从coref mentions
到entity mentions
的地图。
您应该能够看到带有提到的coref的corefClusterID
属性的链id。因此,您有一个coref mention
到entity mention
的映射,您可以通过访问coref提及的corefClusterID
将coref mention
转换为链id。