<commit_before>import os
import re
import wikipedia
from twitter import *

MY_TWITTER_CREDS = os.path.expanduser('./.genderbot_credentials')
CONSUMER_KEY = os.environ['CONSUMER_KEY']
CONSUMER_SECRET = os.environ['CONSUMER_SECRET']

if not os.path.exists(MY_TWITTER_CREDS):
  oauth_dance("CustomGender", CONSUMER_KEY, CONSUMER_SECRET, MY_TWITTER_CREDS)

oauth_token, oauth_secret = read_token_file(MY_TWITTER_CREDS)
twitter = Twitter(auth=OAuth(
  oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))

try:
  # Grab a random article from Wikipedia<commit_msg>Randomly tweet only half the time when run<commit_after>import json
import os
import random
import re
import sys
from twitter import *
import wikipedia

if random.randrange(2) == 0: sys.exit(0)

MY_TWITTER_CREDS = os.path.join(os.path.dirname(__file__), ".genderbot_credentials")

env_filepath = os.path.join(os.path.dirname(__file__), ".env")
env_file = open(env_filepath, 'r')
env_data = json.load(env_file)
CONSUMER_KEY = str(env_data['CONSUMER_KEY'])
CONSUMER_SECRET = str(env_data['CONSUMER_SECRET'])
env_file.close()

if not os.path.exists(MY_TWITTER_CREDS):
  oauth_dance("CustomGender", CONSUMER_KEY, CONSUMER_SECRET, MY_TWITTER_CREDS)

oauth_token, oauth_secret = read_token_file(MY_TWITTER_CREDS)
twitter = Twitter(auth=OAuth(
  oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))

try:
  # Grab a random article from Wikipedia
{'fraction_non_alphanumeric': 0.10369318181818182, 'fraction_numerical': 0.002130681818181818, 'mean_word_length': 7.437125748502994, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2426531', 'n_tokens_mistral': 569, 'n_tokens_neox': 546, 'n_words': 102}