Spaces:
Runtime error
Runtime error
Update app.py
#1
by
ierhon
- opened
app.py
CHANGED
@@ -2,14 +2,17 @@ import gradio as gr
|
|
2 |
import random
|
3 |
import markovify
|
4 |
|
|
|
|
|
|
|
5 |
def gen(text):
|
6 |
text = text.lower()
|
7 |
size = random.randint(1, 650)
|
8 |
file_name = "./dataset.txt"
|
9 |
with open(file_name, "a", encoding="utf-8") as f:
|
10 |
-
f
|
11 |
-
|
12 |
-
db
|
13 |
db = db.strip().lower()
|
14 |
text_model = markovify.NewlineText(input_text=db, state_size=1, well_formed=False)
|
15 |
symbolsplus = [".","~~","!","?"]
|
@@ -22,5 +25,5 @@ iface = gr.Interface(
|
|
22 |
fn=gen,
|
23 |
inputs="text",
|
24 |
outputs="text",
|
25 |
-
examples=[["Привет!"], ["Как дела?"]])
|
26 |
iface.launch()
|
|
|
2 |
import random
|
3 |
import markovify
|
4 |
|
5 |
+
with open(file_name, encoding="utf-8") as f:
|
6 |
+
db = f.read()
|
7 |
+
|
8 |
def gen(text):
|
9 |
text = text.lower()
|
10 |
size = random.randint(1, 650)
|
11 |
file_name = "./dataset.txt"
|
12 |
with open(file_name, "a", encoding="utf-8") as f:
|
13 |
+
v = f"{text}\n"
|
14 |
+
f.write(v)
|
15 |
+
db += v
|
16 |
db = db.strip().lower()
|
17 |
text_model = markovify.NewlineText(input_text=db, state_size=1, well_formed=False)
|
18 |
symbolsplus = [".","~~","!","?"]
|
|
|
25 |
fn=gen,
|
26 |
inputs="text",
|
27 |
outputs="text",
|
28 |
+
examples=[["Привет!"], ["Как дела?"], ["Как"]])
|
29 |
iface.launch()
|