<commit_before># encoding: utf-8

class Grapher

  def generate_cumul_graph(opts = {})
    title = opts[:title]
    filename = opts[:filename]
    attribute = opts[:attribute]
    cumuls = opts[:cumuls]
    legend = opts[:legend]
    Gchart.bar(:title => "Semaines de présence",
               :format => 'file', :filename => "img/#{filename}",
               :data => [
                 [cumuls[0].sum(attribute) / cumuls[0].count],
                 [cumuls[1].sum(attribute) / cumuls[1].count],
                 [cumuls[2].sum(attribute) / cumuls[2].count],
                 [cumuls[3].sum(attribute) / cumuls[3].count],
                 [cumuls[4].sum(attribute) / cumuls[4].count],
               ],
               :stacked => false,
               :bar_colors => ['CFF09E','A8DBA8','79BD9A','3B8686','0B486B'],
               :size => "500x200",
               :legend => [
                 "#{cumuls[0].count} députés - moyenne: #{cumuls[0].sum(attribute) / cumuls[0].count} #{legend}",
                 "#{cumuls[1].count} députés - moyenne: #{cumuls[1].sum(attribute) / cumuls[1].count} #{legend}",
                 "#{cumuls[2].count} députés - moyenne: #{cumuls[2].sum(attribute) / cumuls[2].count} #{legend}",
                 "#{cumuls[3].count} députés - moyenne: #{cumuls[3].sum(attribute) / cumuls[3].count} #{legend}",
                 "#{cumuls[4].count} député  - moyenne: #{cumuls[4].sum(attribute) / cumuls[4].count} #{legend}"
               ])
  end

  def show_cumul(deputies)
    cumuls = [
      deputies.all :nb_cumul => 0,
      deputies.all :nb_cumul => 1,
      deputies.all :nb_cumul => 2,
      deputies.all :nb_cumul => 3,
      deputies.all :nb_cumul => 4
    ]

    generate_cumul_graph :title => "Semaines de présence",
                         :filename => "cumul_weeks.png",
                         :attribute => :activity_weeks,
                         :cumuls => cumuls,
                         :legend => "semaines"

    generate_cumul_graph :title => "Présences en commission",
                         :filename => "cumul_commission_presence.png",
                         :attribute => :commisssion_presence,
                         :cumuls => cumuls,
                         :legend => "présences"

    generate_cumul_graph :title => "Interventions en commission",
                         :filename => "cumul_commission_intervention.png",
                         :attribute => :commission_intervention,
                         :cumuls => cumuls,
                         :legend => "interventions"

    generate_cumul_graph :title => "Intervention en hémicycle",
                         :filename => "cumul_hemicycle_intervention.png",
                         :attribute => :hemicycle_intervention,
                         :cumuls => cumuls,
                         :legend => "interventions"

    generate_cumul_graph :title => "Amendements signés",
                         :filename => "cumul_amendements.png",
                         :attribute => :signed_amendment,
                         :cumuls => cumuls,<commit_msg>correct typo<commit_after># encoding: utf-8

class Grapher

  def generate_cumul_graph(opts = {})
    title = opts[:title]
    filename = opts[:filename]
    attribute = opts[:attribute]
    cumuls = opts[:cumuls]
    legend = opts[:legend]
    Gchart.bar(:title => "Semaines de présence",
               :format => 'file', :filename => "img/#{filename}",
               :data => [
                 [cumuls[0].sum(attribute) / cumuls[0].count],
                 [cumuls[1].sum(attribute) / cumuls[1].count],
                 [cumuls[2].sum(attribute) / cumuls[2].count],
                 [cumuls[3].sum(attribute) / cumuls[3].count],
                 [cumuls[4].sum(attribute) / cumuls[4].count],
               ],
               :stacked => false,
               :bar_colors => ['CFF09E','A8DBA8','79BD9A','3B8686','0B486B'],
               :size => "500x200",
               :legend => [
                 "#{cumuls[0].count} députés - moyenne: #{cumuls[0].sum(attribute) / cumuls[0].count} #{legend}",
                 "#{cumuls[1].count} députés - moyenne: #{cumuls[1].sum(attribute) / cumuls[1].count} #{legend}",
                 "#{cumuls[2].count} députés - moyenne: #{cumuls[2].sum(attribute) / cumuls[2].count} #{legend}",
                 "#{cumuls[3].count} députés - moyenne: #{cumuls[3].sum(attribute) / cumuls[3].count} #{legend}",
                 "#{cumuls[4].count} député  - moyenne: #{cumuls[4].sum(attribute) / cumuls[4].count} #{legend}"
               ])
  end

  def show_cumul(deputies)
    cumuls = [
      deputies.all(:nb_cumul => 0),
      deputies.all(:nb_cumul => 1),
      deputies.all(:nb_cumul => 2),
      deputies.all(:nb_cumul => 3),
      deputies.all(:nb_cumul => 4)
    ]

    generate_cumul_graph :title => "Semaines de présence",
                         :filename => "cumul_weeks.png",
                         :attribute => :activity_weeks,
                         :cumuls => cumuls,
                         :legend => "semaines"

    generate_cumul_graph :title => "Présences en commission",
                         :filename => "cumul_commission_presence.png",
                         :attribute => :commisssion_presence,
                         :cumuls => cumuls,
                         :legend => "présences"

    generate_cumul_graph :title => "Interventions en commission",
                         :filename => "cumul_commission_intervention.png",
                         :attribute => :commission_intervention,
                         :cumuls => cumuls,
                         :legend => "interventions"

    generate_cumul_graph :title => "Intervention en hémicycle",
                         :filename => "cumul_hemicycle_intervention.png",
                         :attribute => :hemicycle_intervention,
                         :cumuls => cumuls,
                         :legend => "interventions"

    generate_cumul_graph :title => "Amendements signés",
                         :filename => "cumul_amendements.png",
                         :attribute => :signed_amendment,
                         :cumuls => cumuls,
{'fraction_non_alphanumeric': 0.1458670988654781, 'fraction_numerical': 0.017179902755267422, 'mean_word_length': 1.7245033112582782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 77, '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': '5495962', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1775, 'n_words': 303}