Stanford CoreNLP provides coreference resolution as mentioned here, also this thread, this, provides some insights about its implementation in Java.
However, I am
stanfordcorenlp, the relatively new wrapper, may work for you.
Suppose the text is "Barack Obama was born in Hawaii. He is the president. Obama was elected in 2008."
The code:
# coding=utf-8
import json
from stanfordcorenlp import StanfordCoreNLP
nlp = StanfordCoreNLP(r'G:\JavaLibraries\stanford-corenlp-full-2017-06-09', quiet=False)
props = {'annotators': 'coref', 'pipelineLanguage': 'en'}
text = 'Barack Obama was born in Hawaii. He is the president. Obama was elected in 2008.'
result = json.loads(nlp.annotate(text, properties=props))
num, mentions = result['corefs'].items()[0]
for mention in mentions:
print(mention)
Every "mention" above is a Python dict like this:
{
"id": 0,
"text": "Barack Obama",
"type": "PROPER",
"number": "SINGULAR",
"gender": "MALE",
"animacy": "ANIMATE",
"startIndex": 1,
"endIndex": 3,
"headIndex": 2,
"sentNum": 1,
"position": [
1,
1
],
"isRepresentativeMention": true
}