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

IndexError while training #1

Open
krmaxwell opened this issue Apr 4, 2015 · 1 comment · May be fixed by #2
Open

IndexError while training #1

krmaxwell opened this issue Apr 4, 2015 · 1 comment · May be fixed by #2

Comments

@krmaxwell
Copy link
Owner

Training MegaHAL on my tweets:

$ megahal -T tweets.txt
Traceback (most recent call last):
  File "/home/kmaxwell/src/megahal/venv/bin/megahal", line 27, in <module>
    sys.exit(main())
  File "/home/kmaxwell/src/megahal/venv/bin/megahal", line 21, in main
    megahal.train(opts.train)
  File "/home/kmaxwell/src/megahal/venv/local/lib/python2.7/site-packages/megahal.py", line 438, in train
    self.learn(line)
  File "/home/kmaxwell/src/megahal/venv/local/lib/python2.7/site-packages/megahal.py", line 442, in learn
    self.__brain.communicate(phrase, reply=False)
  File "/home/kmaxwell/src/megahal/venv/local/lib/python2.7/site-packages/megahal.py", line 207, in communicate
    words = self.get_words_from_phrase(phrase)
  File "/home/kmaxwell/src/megahal/venv/local/lib/python2.7/site-packages/megahal.py", line 192, in get_words_from_phrase
    if boundary(phrase, offset):
  File "/home/kmaxwell/src/megahal/venv/local/lib/python2.7/site-packages/megahal.py", line 172, in boundary
    string[position + 1].isalpha()):
IndexError: string index out of range
Closing database
@krmaxwell
Copy link
Owner Author

So line 172:

string[position + 1].isalpha()): 

Clearly if we're at the end of string, this is out of range. Adding a quick length check.

@krmaxwell krmaxwell linked a pull request Apr 12, 2015 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant