txlyre 1 月之前
父節點
當前提交
e9e599371e
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      markov.py

+ 4 - 2
markov.py

@@ -38,10 +38,12 @@ class Markov:
           
             if size < config.MARKOV_STATE_SIZE:                
                 init_state = (markovify.chain.BEGIN,) * (config.MARKOV_STATE_SIZE - size) + init_state            
-        
+            elif size > config.MARKOV_STATE_SIZE:
+                init_state = init_state[:-config.MARKOV_STATE_SIZE]
+
         words = self.chain.walk(init_state)
         if not words:
-            return self.generate()
+            return self.generate(init_state)
 
         text = orig_init_state if orig_init_state is not None else ""
         for word in words: