Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding @conspiracy_r to "In The Wild" section #110

Closed
wants to merge 1 commit into from

Conversation

tonyravioli
Copy link

No description provided.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 59f64fe on tonyravioli:master into 6968649 on jsvine:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 59f64fe on tonyravioli:master into 6968649 on jsvine:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 59f64fe on tonyravioli:master into 6968649 on jsvine:master.

@jsvine
Copy link
Owner

jsvine commented Mar 17, 2019

Thank you for the suggestion. Do you happen to have a link to the code used for this example?

@tonyravioli
Copy link
Author

I don't have it hosted on Github (yet(?)), but here's the code:

#!/usr/bin/env python3
import tweepy
import markovify.text

ckey = "[redacted]"
csecret = "[redacted]"

akey = "[redacted]"
asecret = "[redacted]"

auth = tweepy.OAuthHandler(ckey, csecret)
auth.set_access_token(akey, asecret)

api = tweepy.API(auth)


logfile = "../../conspiradump.txt"
with open(logfile) as f:
    text = f.read()
model = markovify.text.NewlineText(text, state_size=3)

def go(sentences=2):
    longstring = ''

    for i in range(sentences):
        try:
            sentence = model.make_sentence(tries=20).strip()
            if sentence.endswith("." or "?"):
                longstring += "{} ".format(sentence)
            else:
                longstring += "{}, ".format(sentence)
        except AttributeError:
            continue
    if longstring.strip().endswith(','):
        return '{}.'.format(longstring.strip()[:-1])
    else:
        return longstring.strip()

generated = go()
while len(generated) > 279:
  generated = go()
  print('too long')

while generated.endswith(('?','.')):
  generated = generated[:-1]
generated = generated.replace('?.','?')
generated = generated.replace('!.','!')

print(generated)
api.update_status(generated)

If you need me to host this on Github, I can do that.

@jsvine
Copy link
Owner

jsvine commented Mar 17, 2019

If you could, that'd be helpful, so that other markovify users can learn from the example. Thanks!

@jsvine
Copy link
Owner

jsvine commented Jan 6, 2020

Closing this PR for lack of activity, but feel free to reopen if you end up hosting the code on GitHub (or elsewhere).

@jsvine jsvine closed this Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants