mirror of
https://github.com/Findus23/se-simulator.git
synced 2024-09-11 06:33:48 +02:00
21 lines
518 B
Python
21 lines
518 B
Python
import markovify
|
|
from sacremoses import MosesDetokenizer, MosesTokenizer
|
|
|
|
tokenizer = MosesTokenizer()
|
|
detokenizer = MosesDetokenizer()
|
|
|
|
|
|
class MarkovText(markovify.Text):
|
|
def word_split(self, sentence):
|
|
return tokenizer.tokenize(sentence)
|
|
|
|
def word_join(self, words):
|
|
return detokenizer.detokenize(words, return_str=True)
|
|
|
|
|
|
class MarkovUserName(markovify.Text):
|
|
def word_split(self, word):
|
|
return list(word)
|
|
|
|
def word_join(self, characters):
|
|
return "".join(characters)
|