|
@@ -28,9 +28,9 @@ class Markov:
|
|
|
return self.chain is not None
|
|
|
|
|
|
def generate(self, init_state=None):
|
|
|
- if isinstance(init_state, str):
|
|
|
- init_state = self.tokenize(init_state)
|
|
|
-
|
|
|
+ if init_state is not None:
|
|
|
+ init_state = tuple(self.tokenize(init_state))
|
|
|
+
|
|
|
words = self.chain.walk(init_state)
|
|
|
if not words:
|
|
|
return self.generate()
|