<commit_before>#!/usr/bin/python
import sys
import argparse
import codecs

from Database import Database
from Markov import SequenceGenerator
from Scraper import scrape

def readFromFile(path, db):
  f = codecs.open(path, 'r', 'utf-8')

  commits = []
  for line in f:
    line = line.strip()
    commits.append((hash(line), line))

  db.addCommits(commits)

def printCommits(db):
  for (hash, msg) in db.allCommits():
    print msg

def generate(db):
  sg = SequenceGenerator(1)
  for commit in db.allCommits():
    sg.addSample(commit[1].split(' '))

  print ' '.join(sg.generate())


def main(argv):
  parser = argparse.ArgumentParser(description='github_ebooks')
  parser.add_argument('--api-key', 
      help='Set the API key used for scraping commits')
  parser.add_argument('--commit-file', 
      help='Read commits from the given file and save them in the database')
  parser.add_argument('--print-api-key', action='store_true')
  parser.add_argument('--print-commits', action='store_true')
  parser.add_argument('--generate', action='store_true')
  parser.add_argument('--scrape')
  args = parser.parse_args(argv[1:])

  db = Database()

  if args.api_key is not None:
    db.setConfigValue('api_key', args.api_key)

  if args.commit_file is not None:<commit_msg>Split on newlines too.<commit_after>#!/usr/bin/python
import sys
import argparse
import codecs

from Database import Database
from Markov import SequenceGenerator
from Scraper import scrape

def readFromFile(path, db):
  f = codecs.open(path, 'r', 'utf-8')

  commits = []
  for line in f:
    line = line.strip()
    commits.append((hash(line), line))

  db.addCommits(commits)

def printCommits(db):
  for (hash, msg) in db.allCommits():
    print msg

def generate(db):
  sg = SequenceGenerator(1)
  for commit in db.allCommits():
    sg.addSample(commit[1].split(' \n'))

  print ' '.join(sg.generate())


def main(argv):
  parser = argparse.ArgumentParser(description='github_ebooks')
  parser.add_argument('--api-key', 
      help='Set the API key used for scraping commits')
  parser.add_argument('--commit-file', 
      help='Read commits from the given file and save them in the database')
  parser.add_argument('--print-api-key', action='store_true')
  parser.add_argument('--print-commits', action='store_true')
  parser.add_argument('--generate', action='store_true')
  parser.add_argument('--scrape')
  args = parser.parse_args(argv[1:])

  db = Database()

  if args.api_key is not None:
    db.setConfigValue('api_key', args.api_key)

  if args.commit_file is not None:
{'fraction_non_alphanumeric': 0.14000782166601486, 'fraction_numerical': 0.003128666405944466, 'mean_word_length': 4.241803278688525, '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': '6463223', 'n_tokens_mistral': 874, 'n_tokens_neox': 833, 'n_words': 213}