<commit_before>module Tychus
  class ParserSelector
    PARSERS = [
      Tychus::Parsers::AllrecipesParser,
      Tychus::Parsers::FoodNetworkParser,
      Tychus::Parsers::KraftRecipesParser,
      Tychus::Parsers::CampbellsKitchenParser
    ]

    def self.resolve_parser(meta_object)
      PARSERS.detect do |parser|
        meta_object.to_s =~ %r[#{parser.uri_host}]
      end
    end

  end
end
<commit_msg>Ugly logic. Requires refactor down the road. If there's no specific parser, but it is using the Schema.org microformat, use the Generic schema org parser<commit_after>module Tychus
  class ParserSelector
    PARSERS = [
      Tychus::Parsers::AllrecipesParser,
      Tychus::Parsers::FoodNetworkParser,
      Tychus::Parsers::KraftRecipesParser,
      Tychus::Parsers::CampbellsKitchenParser
    ]

    def self.resolve_parser(meta_object)
      parser = PARSERS.detect do |parser|
        meta_object.to_s =~ %r[#{parser.uri_host}]
      end

      if parser.blank?
        if meta_object.schema_org_microformat?
          return Tychus::Parsers::SchemaOrgParser
        end

        raise("No parser found")
      end
      parser
    end

  end
end

{'fraction_non_alphanumeric': 0.08669527896995709, 'fraction_numerical': 0.0, 'mean_word_length': 3.076923076923077, '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': '5805401', 'n_tokens_mistral': 384, 'n_tokens_neox': 374, 'n_words': 77}