<commit_before>require 'rubygems'
require 'sinatra'
require 'sinatra/base'

require 'erb'

require 'chartkick'
require 'sigma'


class ChartController

  attr_accessor :title
  attr_accessor :lines

  def initialize
    @lines = []
    @title = "Sample Chart"
  end

end

class ChartsWebapp < Sinatra::Base

	def initialize 
		super
		@confDir = ENV['TINY_FORECAST_HOME']
		@confDir = File.dirname(__FILE__) + '/../conf/' if @confDir.nil?
	end

	def createLoader id
	  fileConfig = @confDir + '/' + id + '-config.yaml'
	  fileData   = @confDir + '/' + id + '-data.yaml'
	  loader = Sigma::YamlDataLoader.new fileConfig, fileData
	  loader.run
	  loader
	end

	def loadSigmaChart controller, loader, params
	  lines = loader.chartData
    controller.lines = lines

    sigma = Sigma::SigmaDateRangeFunction.new loader.endDate
    sigma.startDate = loader.startDate
    sigma.addAllFactors loader.factors
    totalLines = sigma.run loader.maxY

	  h =  { :name => 'best-expected-line', :data => totalLines }
	  controller.lines.push h
	end

	get '/charts/:id/:file.html' do
	  file = params['file']
	  loader = createLoader params['id']
	  
	  controller = ChartController.new  
	  controller.title = params['id']
	  
	  loadSigmaChart(controller, loader, params) if file == 'sigma'
		
	  template = loader.template + '-' + file
	  layout = loader.template + '-layout'<commit_msg>rename sigma line<commit_after>require 'rubygems'
require 'sinatra'
require 'sinatra/base'

require 'erb'

require 'chartkick'
require 'sigma'


class ChartController

  attr_accessor :title
  attr_accessor :lines

  def initialize
    @lines = []
    @title = "Sample Chart"
  end

end

class ChartsWebapp < Sinatra::Base

	def initialize 
		super
		@confDir = ENV['TINY_FORECAST_HOME']
		@confDir = File.dirname(__FILE__) + '/../conf/' if @confDir.nil?
	end

	def createLoader id
	  fileConfig = @confDir + '/' + id + '-config.yaml'
	  fileData   = @confDir + '/' + id + '-data.yaml'
	  loader = Sigma::YamlDataLoader.new fileConfig, fileData
	  loader.run
	  loader
	end

	def loadSigmaChart controller, loader, params
	  lines = loader.chartData
    controller.lines = lines

    sigma = Sigma::SigmaDateRangeFunction.new loader.endDate
    sigma.startDate = loader.startDate
    sigma.addAllFactors loader.factors
    totalLines = sigma.run loader.maxY

	  h =  { :name => 'validation line', :data => totalLines }
	  controller.lines.push h
	end

	get '/charts/:id/:file.html' do
	  file = params['file']
	  loader = createLoader params['id']
	  
	  controller = ChartController.new  
	  controller.title = params['id']
	  
	  loadSigmaChart(controller, loader, params) if file == 'sigma'
		
	  template = loader.template + '-' + file
	  layout = loader.template + '-layout'
{'fraction_non_alphanumeric': 0.117519042437432, 'fraction_numerical': 0.0, 'mean_word_length': 3.405750798722045, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3576221', 'n_tokens_mistral': 953, 'n_tokens_neox': 872, 'n_words': 220}