예제 #1
0
def test_markov_with_higher_level(size=100, file_name="sample1.txt", level=2):
    mark = markov.train_model_higher(
        level, normalize(os.getcwd() + "\\samples\\" + file_name))
    text = markov.generate_sentence(size, mark)
    save_text(text)
    save_long_file(text, file_name)
    print(text)
예제 #2
0
def test_markov(size=100, file_name="sample1.txt"):
    mark = markov.train_model(
        normalize(os.getcwd() + "\\samples\\" + file_name))
    text = markov.generate_sentence(size, mark)
    save_text(text)
    save_long_file(text, file_name)
    print(text)
예제 #3
0
def gen_post():
    # email = emails[random.randint(0, len(emails) - 1)]
    n = 1000
    COUNTY = False
    CITY = False

    for i in range(n):
        if i > (n / 3):
            COUNTY = True
        if i > (2 * n / 3):
            CITY = True

        user_id = random.randint(0, 1000)

        title = mk.generate_sentence(1)

        content = mk.generate_sentence(random.randint(2, 5))

        state = random.randint(1, 51)

        if CITY:
            loc = gen_locations("CITY", state)
            loc = loc[random.randint(0, len(loc) - 1)]
            state = -1
            county = -1
            city = loc[2]

        elif COUNTY:
            loc = gen_locations("COUNTY", state)
            loc = loc[random.randint(0, len(loc) - 1)]
            state = -1
            county = loc[1]
            city = -1

        else:
            state = 9
            county = -1
            city = -1

        print(user_id)
        print(title)
        print(content)
        print(state)
        print(county)
        print(city)
예제 #4
0
def on_button_click(n, current_sub):
    if n is None:
        return ""
    else:
        start_df = matrices[current_sub]["start_df"]
        one_df = matrices[current_sub]["one_df"]
        two_df = matrices[current_sub]["two_df"]
        sentence = markov.generate_sentence(start_df, one_df, two_df, 1, 15)
        return sentence
예제 #5
0
def gen_post():
	#email = emails[random.randint(0, len(emails) - 1)]
	n = 10000

	for i in range(n):
		post_id = random.randint(0, 1000)

		user_id = random.randint(0, 1000)

		content = mk.generate_sentence(random.randint(2, 5))

		print(user_id)
		print(post_id)
		print(content)
예제 #6
0
def test_generate_sentence(mock_model, mock_bot, message):
    markov.generate_sentence(message)
    assert mock_model.called_once_with(message.chat)
    assert mock_bot.send_message.called is True
예제 #7
0
def index():
    return render_template('index.html', sentence=generate_sentence())
예제 #8
0
								consumer_secret, 
								access_token_key, 
								access_token_secret, 
								sleep_on_rate_limit=True,
								tweet_mode='extended')
	except:
		print("Something went wrong with authentication. Did you set your environment variables properly?")
		sys.exit(2)

	if not args.handles is None:
		for celebrity in args.handles:
			print("Fetching ", celebrity, "'s tweets...")
			train(twitter_api, data_table, celebrity)
		
	print("Generating tweets...")
	while(True):
		# Take screenshot and check the size
		TMWScrCapPrint.takeScreenshot(capturePath)
		TMWScrCapPrint.printImage(capturePath)
		
		# Generates a sentence, tweets it, then sleeps.
		text = markov.generate_sentence(data_table)

		try:
			twitter_api.PostUpdate(text.capitalize(), media='%s/TweetTweet.png' %capturePath)
		except twitter.error.TwitterError:
			pass

		print("New tweet: ", text)
		time.sleep(interval - ((time.time() - startTime) % interval))
예제 #9
0
from markov import generate_sentence'kj'

print(generate_sentence())