<commit_before>require_relative 'pitch'

class Dodecaphony

  attr_reader :original_row

  def initialize tone_row, spelling=:sharps
    self.original_row = tone_row
    self.normalized_row = normalize_row spelling: spelling
  end

  def p0
    normalized_row
  end

  private

  def normalize_row sharps=true
    row = get_pitches
    row.each_with_object([]) do |pitch, a|
      a << (sharps ? pitch.spell_as_sharp : pitch.spell_as_flat)
    end
  end

  def get_pitches
    original_row.each_with_object([]) do |pitch_name, a|
      a << Pitch.new(pitch_name)
    end
  end

  attr_reader :normalized_row

  attr_writer :original_row, :normalized_row

end<commit_msg>Major refactor, rethinking storage of rows<commit_after>require_relative 'pitch'

class Dodecaphony

  attr_reader :original_row

  def initialize tone_row, spelling=:sharps
    self.original_row = create_row_with_pitches tone_row
  end

  def spell_with_sharps
    normalize_row :spell_as_sharp
  end

  def p0
    original_row.each_with_object([]) do |pitch, row|
      row << pitch.name
    end
  end

  private

  def create_row_with_pitches tone_row
    tone_row.each_with_object([]) do |pitch, row|
      row << Pitch.new(pitch)
    end
  end

  def normalize_row message
   original_row.each_with_object([]) do |pitch, row|
     row << pitch.send(message)
    end
  end


  attr_writer :original_row

end
{'fraction_non_alphanumeric': 0.07241129616220131, 'fraction_numerical': 0.001448225923244026, 'mean_word_length': 3.6066666666666665, 'pattern_counts': {'":': 0, '<': 13, '<?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': '1258974', 'n_tokens_mistral': 513, 'n_tokens_neox': 479, 'n_words': 112}