Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in link_entities_in_raw_input #11

Open
neemashahbazi opened this issue Apr 21, 2020 · 1 comment
Open

Exception in link_entities_in_raw_input #11

neemashahbazi opened this issue Apr 21, 2020 · 1 comment

Comments

@neemashahbazi
Copy link

neemashahbazi commented Apr 21, 2020

I'm facing the following while trying to run this code:
from entitylinking import core

entitylinker = core.MLLinker(path_to_model="trainedmodels/VectorModel_114.torchweights") output = entitylinker.link_entities_in_raw_input("Barack Obama is a president.") print(output.entities)

/Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/env/bin/python /Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/entitylinking/core/entity_linker.py


File "/Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/entitylinking/core/entity_linker.py", line 122, in main.BaseLinker.link_entities_in_raw_input
Failed example:
l.link_entities_in_raw_input("Who wrote the song hotel California?")
Expected:
[('Q7366', 'song', (14, 18), [3]), ('Q780394', 'Hotel California', (19, 35), [4, 5])]
Got:
Sentence({'input_text': 'Who wrote the song hotel California?', 'tagged': [{'word': 'Who', 'index': 1, 'ner': 'O', 'characterOffsetEnd': 3, 'characterOffsetBegin': 0, 'lemma': 'who', 'pos': 'WP', 'abs_id': 0}, {'word': 'wrote', 'index': 2, 'ner': 'O', 'characterOffsetEnd': 9, 'characterOffsetBegin': 4, 'lemma': 'write', 'pos': 'VBD', 'abs_id': 1}, {'word': 'the', 'index': 3, 'ner': 'O', 'characterOffsetEnd': 13, 'characterOffsetBegin': 10, 'lemma': 'the', 'pos': 'DT', 'abs_id': 2}, {'word': 'song', 'index': 4, 'ner': 'O', 'characterOffsetEnd': 18, 'characterOffsetBegin': 14, 'lemma': 'song', 'pos': 'NN', 'abs_id': 3}, {'word': 'hotel', 'index': 5, 'ner': 'O', 'characterOffsetEnd': 24, 'characterOffsetBegin': 19, 'lemma': 'hotel', 'pos': 'NN', 'abs_id': 4}, {'word': 'California', 'index': 6, 'ner': 'STATE_OR_PROVINCE', 'characterOffsetEnd': 35, 'characterOffsetBegin': 25, 'lemma': 'California', 'pos': 'NNP', 'abs_id': 5}, {'word': '?', 'index': 7, 'ner': 'O', 'characterOffsetEnd': 36, 'characterOffsetBegin': 35, 'lemma': '?', 'pos': '.', 'abs_id': 6}], 'mentions': None, 'entities': []})


File "/Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/entitylinking/core/entity_linker.py", line 124, in main.BaseLinker.link_entities_in_raw_input
Failed example:
l.link_entities_in_raw_input("Donovan McNabb'strade to the Vikings is in place.") # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
Expected:
[('Q963185', 'Donovan McNabb', (0, 14), [0, 1]), ...]
Got:
Sentence({'input_text': "Donovan McNabb'strade to the Vikings is in place.", 'tagged': [{'word': 'Donovan', 'index': 1, 'ner': 'PERSON', 'characterOffsetEnd': 7, 'characterOffsetBegin': 0, 'lemma': 'Donovan', 'pos': 'NNP', 'abs_id': 0}, {'word': 'McNabb', 'index': 2, 'ner': 'PERSON', 'characterOffsetEnd': 14, 'characterOffsetBegin': 8, 'lemma': 'McNabb', 'pos': 'NNP', 'abs_id': 1}, {'word': '', 'index': 3, 'ner': 'O', 'characterOffsetEnd': 15, 'characterOffsetBegin': 14, 'lemma': '', 'pos': '``', 'abs_id': 2}, {'word': 'strade', 'index': 4, 'ner': 'O', 'characterOffsetEnd': 21, 'characterOffsetBegin': 15, 'lemma': 'strade', 'pos': 'VB', 'abs_id': 3}, {'word': 'to', 'index': 5, 'ner': 'O', 'characterOffsetEnd': 24, 'characterOffsetBegin': 22, 'lemma': 'to', 'pos': 'TO', 'abs_id': 4}, {'word': 'the', 'index': 6, 'ner': 'O', 'characterOffsetEnd': 28, 'characterOffsetBegin': 25, 'lemma': 'the', 'pos': 'DT', 'abs_id': 5}, {'word': 'Vikings', 'index': 7, 'ner': 'PERSON', 'characterOffsetEnd': 36, 'characterOffsetBegin': 29, 'lemma': 'Vikings', 'pos': 'NNPS', 'abs_id': 6}, {'word': 'is', 'index': 8, 'ner': 'O', 'characterOffsetEnd': 39, 'characterOffsetBegin': 37, 'lemma': 'be', 'pos': 'VBZ', 'abs_id': 7}, {'word': 'in', 'index': 9, 'ner': 'O', 'characterOffsetEnd': 42, 'characterOffsetBegin': 40, 'lemma': 'in', 'pos': 'IN', 'abs_id': 8}, {'word': 'place', 'index': 10, 'ner': 'O', 'characterOffsetEnd': 48, 'characterOffsetBegin': 43, 'lemma': 'place', 'pos': 'NN', 'abs_id': 9}, {'word': '.', 'index': 11, 'ner': 'O', 'characterOffsetEnd': 49, 'characterOffsetBegin': 48, 'lemma': '.', 'pos': '.', 'abs_id': 10}], 'mentions': None, 'entities': []})


File "/Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/entitylinking/core/entity_linker.py", line 126, in main.BaseLinker.link_entities_in_raw_input
Failed example:
l.link_entities_in_raw_input("what was the queen album?")
Exception raised:
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/doctest.py", line 1329, in __run
compileflags, 1), test.globs)
File "<doctest main.BaseLinker.link_entities_in_raw_input[3]>", line 1, in
l.link_entities_in_raw_input("what was the queen album?")
File "/Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/entitylinking/core/entity_linker.py", line 130, in link_entities_in_raw_input
sentence = self.link_entities_in_sentence_obj(sentence, element_id=element_id, num_candidates=num_candidates)
File "/Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/entitylinking/core/entity_linker.py", line 77, in link_entities_in_sentence_obj
caseless=sentence_obj.input_text.islower())
File "/Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/entitylinking/utils.py", line 133, in get_tagged_from_server
properties={**corenlp_properties, **corenlp_caseless} if caseless else corenlp_properties
AttributeError: 'str' object has no attribute 'get'


File "/Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/entitylinking/core/entity_linker.py", line 68, in main.BaseLinker.link_entities_in_sentence_obj
Failed example:
l.link_entities_in_sentence_obj(Sentence("Where does Norway get their oil?")).entities[0]['linkings'] # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
Exception raised:
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/doctest.py", line 1329, in __run
compileflags, 1), test.globs)
File "<doctest main.BaseLinker.link_entities_in_sentence_obj[1]>", line 1, in
l.link_entities_in_sentence_obj(Sentence("Where does Norway get their oil?")).entities[0]['linkings'] # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
IndexError: list index out of range


File "/Users/nimashahbazi/PycharmProjects/starsem2018-entity-linking-master/entitylinking/core/entity_linker.py", line 356, in main.resolve_entity_overlap_beam_search
Failed example:
resolve_entity_overlap_beam_search([{'linkings':[{}], 'drop_score':0.7, 'token_ids':[0,1,2,3,4]}, {'linkings':[{}], 'drop_score':0.6, 'token_ids':[1,2]}, {'linkings':[{}], 'drop_score':0.78, 'token_ids':[3,4]}, {'linkings':[{}], 'drop_score':0.8, 'token_ids':[5,6]}])
Expected nothing
Got:
[{'linkings': [{}], 'drop_score': 0.6, 'token_ids': [1, 2]}, {'linkings': [{}], 'drop_score': 0.78, 'token_ids': [3, 4]}, {'linkings': [{}], 'drop_score': 0.8, 'token_ids': [5, 6]}]


3 items had failures:
3 of 4 in main.BaseLinker.link_entities_in_raw_input
1 of 2 in main.BaseLinker.link_entities_in_sentence_obj
1 of 1 in main.resolve_entity_overlap_beam_search
Test Failed 5 failures.
TestResults(failed=5, attempted=11)

Any ideas how I should resolve it?

@daniilsorokin
Copy link
Contributor

Hi!

Do you have the Wikidata backend configured?

And the second issues seems to be that your environment is configured to run the doctests first. I would turn that off. I have put some doctests in there as examples, but I am not sure those will all pass, as the output is often non-deterministic.

Best,
Daniil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants