<commit_before>#!/usr/bin/env ruby
require './Point'

NBPOINT = 20

class TraceConverter
  attr_accessor :tab_point

  def initialize(args)
    @tab_point = args
  end

  #Modifie l'attribut tab_point
  #Change la zone de travail pour avoir la plus petite zone possible contenant la lettre
  #Puis remet les points à une échelle 100*100
  def resize
    @tab_point = self.select_n

    min_x, min_y, max_x, max_y = max_min
    #Changement de la zone de travail
    @tab_point = tab_point.map { | point | Point.new(point.x-min_x, point.y-min_y)}

    max_x-=min_x
    max_y-=min_y

    #si min = max
    if max_y == 0
      max_y = 1
    end
    if max_x == 0
      max_x = 1
    end

    #Echelle 100*100
    #Test si max_x/max_y trop petit
    #On ajoute juste 50 au points
    @tab_point = tab_point.map { | point | Point.new(point.x*100/max_x, point.y*100/max_y)}<commit_msg>Meilleur gestion du resize (bug I)<commit_after>#!/usr/bin/env ruby
require './Point'

NBPOINT = 20

class TraceConverter
  attr_accessor :tab_point

  def initialize(args)
    @tab_point = args
  end

  #Modifie l'attribut tab_point
  #Change la zone de travail pour avoir la plus petite zone possible contenant la lettre
  #Puis remet les points à une échelle 100*100
  def resize
    @tab_point = self.select_n

    min_x, min_y, max_x, max_y = max_min
    #Changement de la zone de travail
    @tab_point = tab_point.map { | point | Point.new(point.x-min_x, point.y-min_y)}

    diff_x = max_x-min_x
    diff_y = max_y-min_y
    max_x-=min_x
    max_y-=min_y

    #si min = max
    if max_y == 0
      max_y = 1
    end
    if max_x == 0
      max_x = 1
    end

    #Echelle 100*100
    #Si min_x/max_x trop petit alors on ajoute juste 50 au points (gestion cas I)
    if diff_x < 10
      @tab_point = tab_point.map { | point | Point.new(point.x+50, point.y*100/max_y)}
    elsif diff_y < 10
      @tab_point = tab_point.map { | point | Point.new(point.x*100/max_x, point.y+50)}
    else
      @tab_point = tab_point.map { | point | Point.new(point.x*100/max_x, point.y*100/max_y)}
    end
{'fraction_non_alphanumeric': 0.09696092619392185, 'fraction_numerical': 0.03183791606367583, 'mean_word_length': 2.764065335753176, 'pattern_counts': {'":': 0, '<': 5, '<?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': '460947', 'n_tokens_mistral': 874, 'n_tokens_neox': 799, 'n_words': 221}