Spaces:
Runtime error
Runtime error
pip64
commited on
Commit
·
cc837db
1
Parent(s):
22d14d5
start
Browse files- app.py +23 -0
- requirements.txt +0 -0
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import markovify
|
| 3 |
+
import random
|
| 4 |
+
|
| 5 |
+
def gen():
|
| 6 |
+
dataset = "./dataset.txt"
|
| 7 |
+
|
| 8 |
+
with open(dataset, encoding="utf-8") as f:
|
| 9 |
+
db = f.read()
|
| 10 |
+
db = db.strip().lower()
|
| 11 |
+
|
| 12 |
+
text_model = markovify.NewlineText(
|
| 13 |
+
input_text=db,
|
| 14 |
+
state_size=1,
|
| 15 |
+
well_formed=False
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
sentence = text_model.make_short_sentence(50)
|
| 19 |
+
|
| 20 |
+
return sentence
|
| 21 |
+
|
| 22 |
+
iface = gr.Interface(fn=gen, outputs="text")
|
| 23 |
+
iface.launch()
|
requirements.txt
ADDED
|
File without changes
|