<commit_before>require 'bioinform/support'
require 'bioinform/data_models/parsers'

module Bioinform
  IndexByLetter = {'A' => 0, 'C' => 1, 'G' => 2, 'T' => 3}
  LetterByIndex = {0 => 'A', 1 => 'C', 2 => 'G', 3 => 'T'}

  class PM
    attr_reader :matrix
    attr_accessor :background, :name
    
    def initialize(input, parser = Parser)
      result = parser.new(input).parse   
      @matrix = result[:matrix]
      @name = result[:name]
      @background = [1, 1, 1, 1]
      raise 'matrix not valid'  unless valid?
    end<commit_msg>choose parser beta<commit_after>require 'bioinform/support'
require 'bioinform/data_models/parsers'

module Bioinform
  IndexByLetter = {'A' => 0, 'C' => 1, 'G' => 2, 'T' => 3}
  LetterByIndex = {0 => 'A', 1 => 'C', 2 => 'G', 3 => 'T'}

  class PM
    attr_reader :matrix
    attr_accessor :background, :name
    
    def choose_parser(input)
      input.is_a?(String) ? StringParser : Parser
    end
    
    def initialize(input, parser = nil)
      parser ||= choose_parser(input)
      result = parser.new(input).parse   
      @matrix = result[:matrix]
      @name = result[:name]
      @background = [1, 1, 1, 1]
      raise 'matrix not valid'  unless valid?
    end
{'fraction_non_alphanumeric': 0.1542904290429043, 'fraction_numerical': 0.019801980198019802, 'mean_word_length': 2.912903225806452, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '2245817', 'n_tokens_mistral': 444, 'n_tokens_neox': 413, 'n_words': 115}