<commit_before>require "./lib/matrix_dd_lpp_t16/matriz.rb"
require "./lib/matrix_dd_lpp_t16/matriz_densa.rb"

module MatrixDdLppT16

  class Matriz_Dispersa < Matriz

    def new_initialize
      @pos = Array.new(@filas)
      for i in 0...@filas
        @pos[i] = {} 
      end
    end

    def initialize(filas, columnas)
      super
      new_initialize
    end

  # Creacion matriz dispersa
    def self.copy(matriz)

    obj = new(matriz.filas, matriz.columnas)

    for i in 0...matriz.filas
      for j in 0...matriz.columnas
        val = matriz.get(i,j)
        if(val != 0)
          obj.pos[i][j] = val
          end
      end
    end
    obj
    end

  # Get

   def get(i, j)
      if(@pos[i][j] != nil)
        return @pos[i][j]
      else
        return 0
      end
    end
 
  # Set

    def set(i, j, val)
      if(val == nil or val == 0)
        @pos[i].delete(j)
      else
        @pos[i][j] = val
      end
    end

  end

end<commit_msg>añadiendo metodo to_s y numero nulo<commit_after>require "./lib/matrix_dd_lpp_t16/matriz.rb"
require "./lib/matrix_dd_lpp_t16/matriz_densa.rb"

module MatrixDdLppT16

  class Matriz_Dispersa < Matriz

    def new_initialize
      @pos = Array.new(@filas)
      for i in 0...@filas
        @pos[i] = {} 
      end
    end

    def initialize(filas, columnas)
      super
      new_initialize
    end

  # Creacion matriz dispersa
    def self.copy(matriz)

    obj = new(matriz.filas, matriz.columnas)

    for i in 0...matriz.filas
      for j in 0...matriz.columnas
        val = matriz.get(i,j)
        if(val != 0)
          obj.pos[i][j] = val
          end
      end
    end
    obj
    end

  # Get

   def get(i, j)
      if(@pos[i][j] != nil)
        return @pos[i][j]
      else
        return 0
      end
    end
 
  # Set

    def set(i, j, val)
      if(val == nil or val == 0)
        @pos[i].delete(j)
      else
        @pos[i][j] = val
      end
    end

# Numeros Nulos
    def num_nulos
       total = @filas*@columnas
       cont = 0

       for i in 0...@filas
         cont += @pos[i].size
       end

       res = total - cont
       res.to_f/total.to_f
     end

# to_s  

    def to_s
      output = ""
      for i in 0...@filas
        output += "Fila #{i}: "
        @pos[i].sort.each{|k, v| output += "#{k}=>#{v} "}
        output += "\n"
      end
      output
    end



  end
end
{'fraction_non_alphanumeric': 0.12077702702702703, 'fraction_numerical': 0.011402027027027027, 'mean_word_length': 1.5806100217864925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '3734702', 'n_tokens_mistral': 943, 'n_tokens_neox': 886, 'n_words': 212}