txlyre 1 month ago
parent
commit
8e3f4b4edc
1 changed files with 6 additions and 1 deletions
  1. 6 1
      markov.py

+ 6 - 1
markov.py

@@ -29,7 +29,12 @@ class Markov:
 
     def generate(self, init_state=None):
         if init_state is not None:
-            init_state = tuple(self.tokenize(init_state))
+            init_state = tuple(init_state)
+
+            size = len(init_state)
+          
+            if size < config.MARKOV_STATE_SIZE:                
+                init_state = (markovify.chain.BEGIN,) * (config.MARKOV_STATE_SIZE - size) + init_state            
         
         words = self.chain.walk(init_state)
         if not words: