Сопоставить CorefChain с CoreEntityMention в Stanford Core NLP - PullRequest
0 голосов
/ 05 декабря 2018

Я хочу построить карту поиска с типом Map<CorefChain, CoreEntityMention>, используя

Map<Integer, Integer> mapping = document.annotation().get(CoreAnnotations.CorefMentionToEntityMentionMappingAnnotation.class);  

, где document - это CoreDocument.

Я пытался получить набор CorefChains и список CoreEntityMentions для построения такой карты, но индексы, похоже, не совпадают.

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}

1 Ответ

0 голосов
/ 06 декабря 2018

Просто чтобы прояснить, есть два типа упоминаний:

coref mentions
entity mentions

Все entity mentions должны быть coref mentions, но не все coref mentions entity mentions.

Как вы обнаружили, существует карта от coref mentions до entity mentions.

Вы должны увидеть идентификатор цепочки со свойством corefClusterID в упоминании coref.Таким образом, у вас есть карта от coref mention до entity mention, и вы можете преобразовать coref mention в идентификатор цепочки, обратившись к corefClusterID из упоминания coref.

...