barrucadu/markov

KeyError: ()

Closed this issue · 2 comments

When I run the following commands

(py3env)manzuoni KingJamesProgramming  17:10:21 $ python3 markov
(Cmd) train 3 --noparagraphs /Users/manzuoni/hax/KingJamesProgramming/train
(Cmd) tokens 350

markov exits with an error:

Warning: using seed 1393452655
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/runpy.py", line 160, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/runpy.py", line 73, in _run_code
    exec(code, run_globals)
  File "markov/__main__.py", line 5, in <module>
    repl.cmdloop()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/cmd.py", line 217, in onecmd
    return func(arg)
  File "markov/repl.py", line 31, in wrapper
    return f(self, args)
  File "markov/repl.py", line 76, in do_tokens
    prefix=args["<prefix>"]))
  File "markov/markovstate.py", line 67, in generate
    return self.generator(chunks)
  File "markov/markovstate.py", line 60, in gen
    tok = next(self.markov)
  File "markov/markov.py", line 72, in __next__
    next = self._choose(self.data[()])
KeyError: ()

Running this on Mac OSX 10.8.5 with Python 3.3.2 in a virtualenv

I just hit this error, my problem turned out to be that train expects a shell glob, not a directory name, I had to add a /* to the end of the path argument to get it to pick up all the files

Ah makes sense. It was indicated in the README but I missed that part. Thanks a bunch