Accompanying code for our *SEM 2018 @ NAACL 2018 paper "Mixing Context Granularities for Improved Entity Linking on Question Answering Data across Entity Categories"
entitylinker = core.MLLinker(path_to_model="trainedmodels/VectorModel_114.torchweights")
output = entitylinker.link_entities_in_raw_input("Where is Taj Mahal located in India?")
print(output)
Hi Daniil
I tried to get some sample sentences working and it seems to be hitting the right endpoints but I get no result for entities
(qa-env) debayan@sda-srv04:~/masterthesis/starsem2018-entity-linking$ python eval.py /data/debayan/anaconda3/envs/qa-env/lib/python3.7/site-packages/torch/nn/_reduction.py:43: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead. warnings.warn(warning.format(ret)) Sentence({'input_text': 'Where is Taj Mahal located in India?', 'tagged': [{'ner': 'O', 'lemma': 'where', 'index': 1, 'pos': 'WRB', 'word': 'Where', 'characterOffsetBegin': 0, 'characterOffsetEnd': 5, 'abs_id': 0}, {'ner': 'O', 'lemma': 'be', 'index': 2, 'pos': 'VBZ', 'word': 'is', 'characterOffsetBegin': 6, 'characterOffsetEnd': 8, 'abs_id': 1}, {'ner': 'MISC', 'lemma': 'Taj', 'index': 3, 'pos': 'NNP', 'word': 'Taj', 'characterOffsetBegin': 9, 'characterOffsetEnd': 12, 'abs_id': 2}, {'ner': 'MISC', 'lemma': 'Mahal', 'index': 4, 'pos': 'NNP', 'word': 'Mahal', 'characterOffsetBegin': 13, 'characterOffsetEnd': 18, 'abs_id': 3}, {'ner': 'O', 'lemma': 'located', 'index': 5, 'pos': 'JJ', 'word': 'located', 'characterOffsetBegin': 19, 'characterOffsetEnd': 26, 'abs_id': 4}, {'ner': 'O', 'lemma': 'in', 'index': 6, 'pos': 'IN', 'word': 'in', 'characterOffsetBegin': 27, 'characterOffsetEnd': 29, 'abs_id': 5}, {'ner': 'COUNTRY', 'lemma': 'India', 'index': 7, 'pos': 'NNP', 'word': 'India', 'characterOffsetBegin': 30, 'characterOffsetEnd': 35, 'abs_id': 6}, {'ner': 'O', 'lemma': '?', 'index': 8, 'pos': '.', 'word': '?', 'characterOffsetBegin': 35, 'characterOffsetEnd': 36, 'abs_id': 7}], 'mentions': None, 'entities': []})
And the hits at wikipedia endpoint look like this
131.220.155.72 - - [23/Oct/2019:14:19:19 +0000] "GET /dbpedia2k18/sparql?query=%0A++++++++DEFINE+input%3Ainference+%27instances%27%0A++++++++%0A++++++++PREFIX+g%3A%3Chttp%3A//wikidata.org/%3E%0A++++++++PREFIX+e%3A%3Chttp%3A//www.wikidata.org/entity/%3E%0A++++++++PREFIX+rdfs%3A%3Chttp%3A//www.w3.org/2000/01/rdf-schema%23%3E%0A++++++++PREFIX+skos%3A%3Chttp%3A//www.w3.org/2004/02/skos/core%23%3E%0A++++++++PREFIX+base%3A%3Chttp%3A//www.wikidata.org/ontology%23%3E%0A++++++++PREFIX+schema%3A%3Chttp%3A//schema.org/%3E%0A++++++++%0A++++++++SELECT+DISTINCT+%3Fe2+%3Fmatchedlabel+%3Flabel+WHERE%0A++++++++%7B%0A++++++++%7B%0A++++++++++++++%7BGRAPH+%3Chttp%3A//wikidata.org/statements%3E+%7B+%3Fe2+e%3AP1549s/e%3AP1549v+%22Located%22%40en%7D%7D+UNION%0A++++++++++++++%7BVALUES+%3Flabelpredicate+%7Brdfs%3Alabel+skos%3AaltLabel%7D%0A++++++++++++++GRAPH+%3Chttp%3A//wikidata.org/terms%3E+%7B%0A++++++++++++++++++++++++++++%3Fe2+%3Flabelpredicate+%3Fmatchedlabel.+%3Fmatchedlabel+bif%3Acontains+%22%27located%27%22%40en++%7D%0A++++++++++++++++++++++++++++FILTER+%28+lang%28%3Fmatchedlabel%29+%3D+%22en%22+%29%0A++++++++++++++++++++++++++++%7D%0A++++++++%7D%0A++++++++FILTER+EXISTS+%7B%7B+GRAPH+g%3Astatements+%7B%7B+%3Fe2+%3Fp+%3Fv+%7D%7D+%7D%7D%0A++++++++FILTER+%28+NOT+EXISTS+%7B%7BGRAPH+g%3Ainstances+%7B%7B%3Fe2+rdf%3Atype+e%3AQ17442446%7D%7D+%7D%7D+%26%26%0A+++++++++++++++++NOT+EXISTS+%7B%7BGRAPH+g%3Ainstances+%7B%7B%3Fe2+rdf%3Atype+e%3AQ15474042%7D%7D+%7D%7D+%26%26%0A+++++++++++++++++NOT+EXISTS+%7B%7BGRAPH+g%3Ainstances+%7B%7B%3Fe2+rdf%3Atype+e%3AQ18616576%7D%7D+%7D%7D+%26%26%0A+++++++++++++++++NOT+EXISTS+%7B%7BGRAPH+g%3Ainstances+%7B%7B%3Fe2+rdf%3Atype+e%3AQ5707594%7D%7D+%7D%7D+%26%26%0A+++++++++++++++++NOT+EXISTS+%7B%7BGRAPH+g%3Ainstances+%7B%7B%3Fe2+rdf%3Atype+e%3AQ427626%7D%7D+%7D%7D+%26%26%0A+++++++++++++++++NOT+EXISTS+%7B%7BGRAPH+g%3Ainstances+%7B%7B%3Fe2+rdf%3Atype+e%3AQ16521%7D%7D+%7D%7D+%26%26%0A+++++++++++++++++NOT+EXISTS+%7B%7BGRAPH+g%3Ainstances+%7B%7B%3Fe2+rdf%3Atype+e%3AQ11173%7D%7D+%7D%7D+++++++++++++++++++++++++++++++%0A++++++++++++%29%0A++++++++BIND+%28STRLEN%28%3Fmatchedlabel%29+as+%3Flen%29%0A++++++++%0A++++++++%7B%0A++++++++GRAPH+%3Chttp%3A//wikidata.org/terms%3E+%7B+%3Fe2+rdfs%3Alabel+%3Flabel+%7D%0A++++++++FILTER+%28+lang%28%3Flabel%29+%3D+%22en%22+%29%0A++++++++%7D%0A++++++++%7D+ORDER+BY+%3Flen+LIMIT+1000&format=json&output=json&results=json HTTP/1.1" 400 1949 "-" "sparqlwrapper 1.8.4 (rdflib.github.io/sparqlwrapper)"
eval.py looks like this
from entitylinking import core
entitylinker = core.MLLinker(path_to_model="trainedmodels/VectorModel_114.torchweights") output = entitylinker.link_entities_in_raw_input("Where is Taj Mahal located in India?") print(output)