<commit_before>class Address < ActiveRecord::Base

  include Provenanceable
  include Validatable

  has_and_belongs_to_many :tags
  belongs_to :user

  after_create :generate_score

  TagType::ALLOWED_LABELS.each do |label|
    define_method(label) do
      tags.select { |g| g.tag_type.label == label }.first
    end
  end

  def generate_score
    town_score = Confidence.create(left: postcode, right: town)
    street_score = Confidence.create(left: postcode, right: street)
    # Get total confidence
    confidence = (823.4 * street_score.value) + (176.6 * town_score.value)
    # Apply heuristic adjustment
    adjusted_score = heuristic_adjustment(confidence)
    # Apply source adjustment
    self.score = adjusted_score * 0.61
  end

  def heuristic_adjustment(confidence)
    t = (Date.today - (valid_at || created_at).to_date).to_f / 365.242 # Using created_at for now as we don't have any other measurement
    hl = 15
    decay = 0.5 ** (t / hl)
    confidence * decay
  end

end<commit_msg>Remove comment<commit_after>class Address < ActiveRecord::Base

  include Provenanceable
  include Validatable

  has_and_belongs_to_many :tags
  belongs_to :user

  after_create :generate_score

  TagType::ALLOWED_LABELS.each do |label|
    define_method(label) do
      tags.select { |g| g.tag_type.label == label }.first
    end
  end

  def generate_score
    town_score = Confidence.create(left: postcode, right: town)
    street_score = Confidence.create(left: postcode, right: street)
    # Get total confidence
    confidence = (823.4 * street_score.value) + (176.6 * town_score.value)
    # Apply heuristic adjustment
    adjusted_score = heuristic_adjustment(confidence)
    # Apply source adjustment
    self.score = adjusted_score * 0.61
  end

  def heuristic_adjustment(confidence)
    t = (Date.today - (valid_at || created_at).to_date).to_f / 365.242 
    hl = 15
    decay = 0.5 ** (t / hl)
    confidence * decay
  end

end
{'fraction_non_alphanumeric': 0.08941418293936279, 'fraction_numerical': 0.02158273381294964, 'mean_word_length': 3.496535796766744, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2719309', 'n_tokens_mistral': 681, 'n_tokens_neox': 622, 'n_words': 159}