<commit_before>require 'i18n'

module CreativeCommonsRails
  class LicenseInfo
    attr_accessor :type, :jurisdiction, :version

    # ensure the license exists in the license index
    def self.find(attributes = {})
      index = license_index
      [:jurisdiction, :version, :type].each do |key|
        raise "You must specify the #{attr} to find a licence" if attributes[key].nil?
        index = index[attributes[key].to_s]
        raise "Unknown license #{key}: #{attributes[key]}" if index.nil? || !index
      end

      LicenseInfo.new(attributes[:type],attributes[:jurisdiction],attributes[:version])
    end

    def initialize(type, jurisdiction, version)
      @type, @jurisdiction, @version = type, jurisdiction, version
    end

    def deed_url
      "http://creativecommons.org/licenses/#{type}/#{version}/#{jurisdiction}/deed.#{language}"
    end
<commit_msg>Accessor methods to expose license index.<commit_after>require 'i18n'

module CreativeCommonsRails
  class LicenseInfo
    attr_accessor :type, :jurisdiction, :version

    # ensure the license exists in the license index
    def self.find(attributes = {})
      index = license_index
      [:jurisdiction, :version, :type].each do |key|
        raise "You must specify the #{attr} to find a licence" if attributes[key].nil?
        index = index[attributes[key].to_s]
        raise "Unknown license #{key}: #{attributes[key]}" if index.nil? || !index
      end

      LicenseInfo.new(attributes[:type],attributes[:jurisdiction],attributes[:version])
    end

    def self.available_jurisdictions
      license_index.keys
    end

    def self.available_types(jurisdiction)
      license_index[jurisdiction.to_s].keys
    end

    def self.available_versions(jurisdiction, type)
      license_index[jurisdiction].select{|k,v| v[type]}.keys
    end

    def initialize(type, jurisdiction, version)
      @type, @jurisdiction, @version = type, jurisdiction, version
    end

    def deed_url
      "http://creativecommons.org/licenses/#{type}/#{version}/#{jurisdiction}/deed.#{language}"
    end

{'fraction_non_alphanumeric': 0.11733462095605987, 'fraction_numerical': 0.001931434089811685, 'mean_word_length': 3.6044444444444443, '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': '4812185', 'n_tokens_mistral': 633, 'n_tokens_neox': 584, 'n_words': 153}