-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
35 lines (27 loc) · 804 Bytes
/
app.py
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
35
from flask import Flask, request, url_for
from listogram import Listogram
from dictogram import Dictogram
from dictionary_words import random_sentence
# from markov import MarkovChain
import os
import sys
'''
TODO: Still need to figure out how to get listogram, dictogram, and
markov chain properly working in Flask app
'''
app = Flask(__name__)
@app.route('/')
def generate_words():
with open('words.txt', 'r') as f:
words = f.read().split(' ')
listo = Listogram(words).listogram_samples(10)
dicto = Dictogram(words).dictogram_samples(10)
histograms = {
0: listo,
1: dicto
}
# sentences = [sentence for (index, sentence) in histograms.items()]
# return sentences
return random_sentence(5, words)
if __name__ == '__main__':
app.run()