コード例 #1
0
def generateMarkovModel():

    markovmodel = markov.main()

    markovmodel.generatemelody()
    pickler = picklejar.system()

    pickler.write("markovmodel", markovmodel)
コード例 #2
0
ファイル: app.py プロジェクト: PhyllisWong/NotreDameTweetGen
def index():
    # perhaps change this variable to random_sentences
    final_sentence = markov.main(text_list)
    # then push that sententence into your data structure
    # then create an algorithm to grab a random index from the data structure
    # set that to final_sentence

    '''NOTE: once your page has been loaded 1000's of times, your data structure
    of going to be huge. Time complexity is still O(1), but it could start to take
    up lots of space. If it gets to that, consider migrating your data to a
    database, and doing a fetch <~~~ don't optimize for this until you need to.
    '''
    return render_template('index.html', final_sentence=final_sentence)
コード例 #3
0
def parse_json():
    """ takes in POST data as JSON from Node app and converts values to make
    them accessible to rest of Flask app """
    if request.method == 'GET':  # only executed with HTTP GET requests
        return """Please send a POST request to use this application.
                For additional information on use of this API, documentation can be
                found at: https://github.com/fchikwekwe/name-ly-API.
                """

    params = request.get_json()

    # get the user's answers and add file extension
    name_number = params['nameNumber']
    gender = params['gender'] + '.txt'
    cultural = params['cultural'] + '.txt'
    literary = params['literary'] + '.txt'

    markov_name = markov.main(name_number, gender, cultural, literary,
                              'corpus.txt')
    return jsonify(name=markov_name)
コード例 #4
0
def test_first_integration(capsys):
    markov.main()
    out, err = capsys.readouterr()
    assert out == "hi there friend.\n", """\
コード例 #5
0
import twitter
import markov

message = markov.main()
print message

api_file = open('api.txt')
api_contents = api_file.read()
api_contents_list = api_contents.split()

api_dict = {}

for item in api_contents_list:
	key_value = item.split(',')
	api_dict[key_value[0]] = key_value[1]


api = twitter.Api(
	consumer_key = api_dict['api_key'],
    consumer_secret = api_dict['api_secret'], 
    access_token_key = api_dict['access_token'], 
    access_token_secret = api_dict['access_token_secret']
    )

status = api.PostUpdate(message)
コード例 #6
0
def submit():
    their_input = request.form['input']
    print "POST"
    # print their_input
    foo = markov.main(their_input)
    return render_template('template.html', my_string=foo)
コード例 #7
0
ファイル: app.py プロジェクト: EconClass/Tweet-Generator
def random_sentence():

    return render_template("main.html", sentence=main())
コード例 #8
0
import sys, random
sys.path.insert(0, './src')
import markov
from flask import Flask, render_template

app = Flask(__name__)

markov_chain = markov.main()


@app.route("/")
def home():
    generate_sentence = markov_chain.generate_sentence(25)
    # return render_template("main.html", sentence=generate_sentence)
    return generate_sentence


if __name__ == "__main__":
    app.run(debug=True)
コード例 #9
0
ファイル: tweet_machine.py プロジェクト: anniee/Markov
import os
import twitter
from markov import main

TWITTER_CONSUMER_KEY = os.environ["TWITTER_CONSUMER_KEY"]
TWITTER_CONSUMER_SECRET = os.environ["TWITTER_CONSUMER_SECRET"]
TWITTER_ACCESS_TOKEN = os.environ["TWITTER_ACCESS_TOKEN"]
TWITTER_ACCESS_TOKEN_SECRET = os.environ["TWITTER_ACCESS_TOKEN_SECRET"]

api = twitter.Api(
    consumer_key=TWITTER_CONSUMER_KEY,
    consumer_secret=TWITTER_CONSUMER_SECRET,
    access_token_key=TWITTER_ACCESS_TOKEN,
    access_token_secret=TWITTER_ACCESS_TOKEN_SECRET
    )

text = main("markov_waka.txt","markov_seagulls.txt")

status = api.PostUpdate(text)
コード例 #10
0
def return_json():
    """ Demonstration of api; returns json result """
    json_name = markov.main(10, 'masculine.txt', 'fantasy.txt', 'modern.txt',
                            'corpus.txt')
    return jsonify(json_name)
コード例 #11
0
import twitter
import markov

message = markov.main()
print message

api_file = open("lanakeys.txt").read()
api_keys = api_file.split()
api_dict = {}

for item in api_keys:
    key_value = item.split(':')
    api_dict[key_value[0]] = key_value[1]

api = twitter.Api(consumer_key=api_dict['consumer_key'],
                  consumer_secret=api_dict['consumer_secret'],
                  access_token_key=api_dict['access_token_key'],
                  access_token_secret=api_dict['access_token_secret'])

status = api.PostUpdate(message)
コード例 #12
0
# main script, uses other modules to generate sentences
from flask import Flask, render_template
# from stochastic_sampling import weighted_random
import markov
import re

app = Flask(__name__)

app.markov = markov.main()


@app.route("/")
def sentence_generator():
    """
    """
    final_sentence = app.markov.create_sentence()

    return render_template("main.html", sentence=final_sentence)
コード例 #13
0
ファイル: tweeter.py プロジェクト: poemusica/HB_Exercise08
import twitter
import markov
import secret

api = twitter.Api(consumer_key=CON_SEC,
                  consumer_secret=CON_SEC_KEY,
                  access_token_key=TOKEN,
                  access_token_secret=TOKEN_KEY)

msg = markov.main()

print msg

status = api.PostUpdate(msg)
コード例 #14
0
def generateWavandKey():
    content = markov.main().generatemelody()
    contentsize = sys.getsizeof(content)
    key = ""

    return [content, contentsize, key]
コード例 #15
0
ファイル: tweeter.py プロジェクト: amcyg/HB_Exercise08
import twitter
import markov
import secret


api = twitter.Api(consumer_key=CON_SEC,
    consumer_secret=CON_SEC_KEY, access_token_key=TOKEN, access_token_secret=TOKEN_KEY)

msg = markov.main()

print msg

status = api.PostUpdate(msg)
コード例 #16
0
def index():
    """ Demonstration of api; returns a web template"""
    index_name = markov.main(10, 'feminine.txt', 'fantasy.txt', 'modern.txt',
                             'corpus.txt')
    return render_template('index.html', index_name=index_name)
コード例 #17
0
async def on_message(message):
    author = message.author
    if message.content.startswith('<@241600786470010881>'):
    	output = main(message.content)
    	await client.send_message(message.channel, output)
コード例 #18
0
ファイル: test_stage1.py プロジェクト: andreebrazeau/markov
def test_first_integration(capsys):
    markov.main()
    out, err = capsys.readouterr()
    assert out == "hi there friend.\n", """\
コード例 #19
0
import os
import twitter
from markov import main

TWITTER_CONSUMER_KEY = os.environ["TWITTER_CONSUMER_KEY"]
TWITTER_CONSUMER_SECRET = os.environ["TWITTER_CONSUMER_SECRET"]
TWITTER_ACCESS_TOKEN = os.environ["TWITTER_ACCESS_TOKEN"]
TWITTER_ACCESS_SECRET = os.environ["TWITTER_ACCESS_SECRET"]

api = twitter.Api(consumer_key=TWITTER_CONSUMER_KEY,
                  consumer_secret=TWITTER_CONSUMER_SECRET,
                  access_token_key=TWITTER_ACCESS_TOKEN,
                  access_token_secret=TWITTER_ACCESS_SECRET)

tweet_string = main()
status = api.PostUpdate(tweet_string)
print tweet_string
print status