File size: 1,125 Bytes
33ccc01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import random
import markovify

def gen():
  if text in ["1091393561192304661","848565511834566677"]
   size = random.randint(1, 650)
   file_name = "./premium.txt"
   with open(file_name, encoding="utf-8") as f:
     db = f.read()
   db = db.strip().lower()
   text_model = markovify.NewlineText(input_text=db, state_size=1, well_formed=False)
   symbolsplus = [".","~~","!","?"]
   sentence: str = text_model.make_short_sentence(size) or random.choice(
       db.splitlines())[:size] + random.choice(symbolsplus)
   return sentence
 else:
   size = random.randint(1, 128)
   file_name = "./free.txt"
   with open(file_name, encoding="utf-8") as f:
     db = f.read()
   db = db.strip().lower()
   text_model = markovify.NewlineText(input_text=db, state_size=1, well_formed=False)
   symbolsplus = [".","~~","!","?"]
   sentence: str = text_model.make_short_sentence(size) or random.choice(
       db.splitlines())[:size] + random.choice(symbolsplus)
   return sentence

iface = gr.Interface(
    fn=gen,
    inputs="text",
    outputs="text",
    examples=[["ID!"], ["Как дела?"]])
iface.launch()