Spaces:
Runtime error
Runtime error
pip64
commited on
Commit
·
32eadcf
1
Parent(s):
4a378c3
upd
Browse files
app.py
CHANGED
@@ -1,7 +1,21 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import random
|
3 |
+
import markovify
|
4 |
|
5 |
+
def gen(text):
|
6 |
+
text = text.lower()
|
7 |
+
file_name = "./dataset.txt"
|
8 |
+
with open(file_name, "a", encoding="utf-8") as f:
|
9 |
+
f.write(f"{text}\n")
|
10 |
+
with open(file_name, encoding="utf-8") as f:
|
11 |
+
db = f.read()
|
12 |
+
db = db.strip().lower()
|
13 |
+
text_model = markovify.NewlineText(input_text=db, state_size=1, well_formed=False)
|
14 |
+
symbolsplus = [".","~~","!","?"]
|
15 |
+
sentence: str = text_model.make_short_sentence(100) or random.choice(
|
16 |
+
db.splitlines())[:100] + random.choice(symbolsplus)
|
17 |
|
18 |
+
return sentence
|
19 |
+
|
20 |
+
iface = gr.Interface(fn=gen, inputs="text", outputs="text")
|
21 |
iface.launch()
|