<commit_before>require 'ostruct'
require 'digest'

module Justiz
  class Contact
    FIELDS = [:court, :location, :post, :phone, :fax, :justiz_id, :url, :email]
    attr_accessor :attributes, *FIELDS

    def initialize(attributes = {})
      self.attributes = attributes
    end

    def attributes=(attributes)
      attributes.each do |key, value|
        send("#{key}=", value) if respond_to?("#{key}=")
      end
    end

    def id
      # too many duplicates
      #[court, justiz_id].compact.join("")
      # currently no duplicates
      [court, email].compact.join("")
    end

    def location_address
      Address.new(location)
    end

    def post_address
      Address.new(post)
    end

    def digest
      sha256 = Digest::SHA2.new
      FIELDS.each do |field|
        sha256 << send(field)
      end
      Digest.hexencode(sha256.digest)
    end
  end<commit_msg>convert field values to string<commit_after>require 'ostruct'
require 'digest'

module Justiz
  class Contact
    FIELDS = [:court, :location, :post, :phone, :fax, :justiz_id, :url, :email]
    attr_accessor :attributes, *FIELDS

    def initialize(attributes = {})
      self.attributes = attributes
    end

    def attributes=(attributes)
      attributes.each do |key, value|
        send("#{key}=", value) if respond_to?("#{key}=")
      end
    end

    def id
      # too many duplicates
      #[court, justiz_id].compact.join("")
      # currently no duplicates
      [court, email].compact.join("")
    end

    def location_address
      Address.new(location)
    end

    def post_address
      Address.new(post)
    end

    def digest
      sha256 = Digest::SHA2.new
      FIELDS.each do |field|
        sha256 << send(field).to_s
      end
      Digest.hexencode(sha256.digest)
    end
  end
{'fraction_non_alphanumeric': 0.11465324384787472, 'fraction_numerical': 0.011185682326621925, 'mean_word_length': 2.5216535433070866, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6097291', 'n_tokens_mistral': 600, 'n_tokens_neox': 563, 'n_words': 145}