<commit_before># Trinary
class Trinary
  attr_reader :trinary
  def initialize(trinary)
    @trinary = trinary
  end

  def to_decimal
    return 0 unless valid?
    trinary.chars.reverse.map.each_with_index do |multiplier, power|
      (3**power) * multiplier.to_i
    end.reduce(:+)
  end

  private

  def valid?
    !trinary.match(/[^0123]/)
  end
end<commit_msg>Trinary: regex fix and each.with_index<commit_after># Trinary
class Trinary
  attr_reader :trinary
  def initialize(trinary)
    @trinary = trinary
  end

  def to_decimal
    return 0 unless valid?
    trinary.chars.reverse.map.with_index do |multiplier, power|
      (3**power) * multiplier.to_i
    end.reduce(:+)
  end

  private

  def valid?
    !trinary.match(/[^0-2]/)
  end
end
{'fraction_non_alphanumeric': 0.1049136786188579, 'fraction_numerical': 0.013280212483399735, 'mean_word_length': 3.212290502793296, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6683371', 'n_tokens_mistral': 282, 'n_tokens_neox': 266, 'n_words': 65}