<commit_before>require 'treetop'
require 'pivotal-tracker'
require 'yaml'

class Pivotxt
  attr_reader :project

  def initialize(stories_file, config_file)
    @stories_file = stories_file
    @config = YAML.load_file(config_file)

    PivotalTracker::Client.token = @config['token']
    @project = PivotalTracker::Project.find(@config['project_id'])
  end

  def load_stories
    grammar = File.join(File.dirname(__FILE__), 'pivtxt.treetop')
    Treetop.load grammar

    parser = PivtxtParser.new
    parser.consume_all_input = false
    tree = parser.parse(File.read(@stories_file).to_s)

    return tree.value
  end

  def upload_stories!
    labeled_groups = load_stories()
    labeled_groups.each do |labeled_group|
      labels = labeled_group[:labels]
      stories = labeled_group[:stories]<commit_msg>allow ssl to be specified in config file<commit_after>require 'treetop'
require 'pivotal-tracker'
require 'yaml'

class Pivotxt
  attr_reader :project

  def initialize(stories_file, config_file)
    @stories_file = stories_file
    @config = YAML.load_file(config_file)

    PivotalTracker::Client.token = @config['token']
    PivotalTracker::Client.use_ssl = @config['ssl'] == true
    @project = PivotalTracker::Project.find(@config['project_id'])
  end

  def load_stories
    grammar = File.join(File.dirname(__FILE__), 'pivtxt.treetop')
    Treetop.load grammar

    parser = PivtxtParser.new
    parser.consume_all_input = false
    tree = parser.parse(File.read(@stories_file).to_s)

    return tree.value
  end

  def upload_stories!
    labeled_groups = load_stories()
    labeled_groups.each do |labeled_group|
      labels = labeled_group[:labels]
      stories = labeled_group[:stories]
{'fraction_non_alphanumeric': 0.10344827586206896, 'fraction_numerical': 0.0, 'mean_word_length': 4.283950617283951, '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': '4688828', 'n_tokens_mistral': 580, 'n_tokens_neox': 563, 'n_words': 107}