keyword-extraction icon indicating copy to clipboard operation
keyword-extraction copied to clipboard

Can't get things working.

Open rafaleo opened this issue 5 years ago • 2 comments

At this line output_evaluation(inp) I get error:

inp = "Little gray mouse fears big brown cat."
output_evaluation(inp)

inp = "Little gray mouse fears big brown cat."

output_evaluation(inp) Traceback (most recent call last):

File "", line 1, in output_evaluation(inp)

File "", line 330, in output_evaluation encoder1, attn_decoder1, input_sentence

File "", line 290, in evaluate input_variable = variable_from_sentence(input_lang, sentence)

File "", line 170, in variable_from_sentence indexes = indexes_from_sentence(lang, sentence)

File "", line 166, in indexes_from_sentence return [lang.word2index[word] for word in sentence.split(' ')]

File "", line 166, in return [lang.word2index[word] for word in sentence.split(' ')]

KeyError: 'Little'

This looks like some compability issue maybe. It's not said the torch library can be installed as PyTorch - in my case I'm unable to install anything else so use Pytorch.

Not sure it's the case.

rafaleo avatar Feb 20 '20 10:02 rafaleo

Found that in the code is many unhandled exceptions. In this situation in:

def indexes_from_sentence(lang, sentence):  #lang=input_lang; sentence=pair[0]    
    sent_spl = sentence.split(' ')
    return [lang.word2index[word] for word in sent_spl **if word in lang.word2index**]

If word is not in the lang.word2index it throws an error. This condition works but don't know whether it's properly set and won't cause errors further on.

Anyway, I have many other errors like:

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number at line encoder_output, encoder_hidden = encoder(input_variable[ei], encoder_hidden) of evaluate functions and many others.

rafaleo avatar Feb 20 '20 12:02 rafaleo

Is it because you are using a period at the end of your sentence? I have never tested that condition, so you can try removing the period and see if that resolves the issue. All punctuation/special characters need to be removed I think.

TheApeMachine avatar Feb 26 '20 15:02 TheApeMachine