|
|
@@ -2,6 +2,7 @@ import os.path
|
|
|
import re
|
|
|
import atexit
|
|
|
import string
|
|
|
+import threading
|
|
|
|
|
|
import spacy
|
|
|
import ujson
|
|
|
@@ -58,11 +59,15 @@ class Markov:
|
|
|
|
|
|
return text.strip()
|
|
|
|
|
|
- def rebuild(self):
|
|
|
+ def _rebuild(self):
|
|
|
self.chain = markovify.Chain(self.corpus, config.MARKOV_STATE_SIZE).compile()
|
|
|
|
|
|
+ def rebuild(self):
|
|
|
self.counter = 0
|
|
|
|
|
|
+ t = threading.Thread(target=self._rebuild)
|
|
|
+ t.start()
|
|
|
+
|
|
|
def tokenize(self, text):
|
|
|
text = re.sub(r"(@[A-Za-z0-9_]+,?)", "", text)
|
|
|
text = re.sub(
|