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

Get ValueError when the Input format is line #18

Closed
imgarylai opened this issue Feb 20, 2018 · 0 comments
Closed

Get ValueError when the Input format is line #18

imgarylai opened this issue Feb 20, 2018 · 0 comments
Assignees

Comments

@imgarylai
Copy link
Member

imgarylai commented Feb 20, 2018

When I use line as input format for sentiment analysis. I got this error message.

ValueError: Error when checking : expected input_2 to have 3 dimensions, but got array with shape (0, 1)

The code I executed is

from elit.decode import EnglishDecoder, DOC_DELIM
from elit.util.configure import *

# Please replace the correct resource path.
RESOURCE_PATH = os.path.join('resources')
local_filename = "test.txt"

config = Configuration(tokenize=True, input_format='line', segment=True, sentiment=(SENTIMENT_TWITTER, SENTIMENT_MOVIE))

nd = EnglishDecoder(resource_dir=RESOURCE_PATH, config=config)

with open(local_filename, 'r', encoding='utf8') as f:
    result = nd.decode(config, StringIO(f.read()))

The file, test.txt, I tested:

Longer version of error messages:

  File "/Users/gary/Documents/research/elitrpc/application.py", line 73, in decode
    result = nd.decode(config, StringIO(f.read()))
  File "/Users/gary/.local/share/virtualenvs/elitrpc36/lib/python3.6/site-packages/elit/decode.py", line 44, in decode
    d = decode(config, istream, ostream)
  File "/Users/gary/.local/share/virtualenvs/elitrpc36/lib/python3.6/site-packages/elit/decode.py", line 89, in decode_line
    d = self.text_to_sentences(config, line, offset)
  File "/Users/gary/.local/share/virtualenvs/elitrpc36/lib/python3.6/site-packages/elit/decode.py", line 182, in text_to_sentences
    self.sentiment_analyze(config, sentences)
  File "/Users/gary/.local/share/virtualenvs/elitrpc36/lib/python3.6/site-packages/elit/decode.py", line 202, in sentiment_analyze
    y, att = analyzer.decode(sens, att=att)
  File "/Users/gary/.local/share/virtualenvs/elitrpc36/lib/python3.6/site-packages/elit/component/sentiment.py", line 73, in decode
    y = self.p_model.predict(x, batch_size=batch_size, verbose=0)
  File "/Users/gary/.local/share/virtualenvs/elitrpc36/lib/python3.6/site-packages/keras/engine/training.py", line 1695, in predict
    check_batch_axis=False)
  File "/Users/gary/.local/share/virtualenvs/elitrpc36/lib/python3.6/site-packages/keras/engine/training.py", line 132, in _standardize_input_data
    str(array.shape))
ValueError: Error when checking : expected input_2 to have 3 dimensions, but got array with shape (0, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants