Exemple #1
0
def gen_markov(source_text="wonderland"):
    if source_text == "wonderland":
        chains = markov.generate_chains("wonderland.txt" )
        text = markov.generate_text( chains, 100 )
        header ="<!DOCTYPE html><html><head><title>Alice In Wonderland</title></head><h1>Markov Generator</h1><center><img src= 'https://upload.wikimedia.org/wikipedia/commons/b/ba/Alice_par_John_Tenniel_30.png' height='200' width = '120'></br><button onclick='myFunction()'>Press me!</button><script> function myFunction(){  alert('WHY DID YOU PRESS ME!!!'); }</script><center></br><p>"
        footer ="</p></html>"
        final = "%s%s%s"%(header,text,footer)
        return final + render_template('base.html')
    elif source_text == "sawyer":
        chains = markov.generate_chains("sawyer.txt" )
        text = markov.generate_text( chains, 100 )
        header ="<!DOCTYPE html><html><head><title>The Adventures of Tom Sawyer</title></head><h1>Markov Generator</h1><img src= 'http://englishbookgeorgia.com/blogebg/wp-content/uploads/2014/06/Tom-Sawyer.jpg' height='200' width= '120'/></br><p>"
        footer ="</p></html>"
        final = "%s%s%s"%(header,text,footer)
        return final + render_template('base.html')
    elif source_text == "sherlock":
        chains = markov.generate_chains("sherlock.txt" )
        text = markov.generate_text( chains, 100 )
        header = "<!DOCTYPE html><html><head><title>The Adventures of Sherlock Holmes</title></head><h1>Markov Generator</h1><img src= 'http://www.internationalhero.co.uk/h/holmes_rathbone.jpg' height= '200' width = '120'/></br><p>"
        footer = "</p></html>"
        final = "%s%s%s"%(header,text,footer)
        return final + render_template('base.html')
    elif source_text == "war_of_the_worlds":
        chains = markov.generate_chains("war_of_the_worlds.txt" )
        text = markov.generate_text( chains, 100 )
        header = "<!DOCTYPE html><html><head><title>War of the Worlds</title></head><h1>Markov Generator</h1><img src='http://www.empireonline.com/images/image_index/300x250/3201.jpg' height='200' width='120'</br><p>"
        footer = "</p></html>"
        final = "%s%s%s"%(header,text,footer)
        return final + render_template('base.html')
    else:
        return("Book is not available at the moment")
Exemple #2
0
def x(source = "sawyer"):
    t = ["sawyer", "sherlock", "wonderland", "war_of_the_worlds"]
    if source not in t:
        return "................"
    x = "%s.txt"%(source)
    chains = markov.generate_chains(x)
    text = markov.generate_text(chains, 100)
    return render_template("markov2.html", final = text, title = "Markov")