<commit_before>class Address < ActiveRecord::Base
  attr_accessor :show_editor

  def copy_from address_to_copy_from
    self.street_1 = address_to_copy_from[:street_1]
    self.street_2 = address_to_copy_from[:street_2]
    self.street_3 = address_to_copy_from[:street_3]
    self.town     = address_to_copy_from[:town]
    self.postcode = address_to_copy_from[:postcode]
    self.save
  end

  def self.create_random
    self.create(generate)
  end

  def self.generate()
    address = {
      :street_1   => Random.address_line_1,
      :street_2   => Random.address_line_2,
      :postcode   => Random.uk_post_code,
      :town       => Random.city
    }
  end
end<commit_msg>Better random address generation<commit_after>class Address < ActiveRecord::Base
  attr_accessor :show_editor

  def copy_from address_to_copy_from
    self.street_1 = address_to_copy_from[:street_1]
    self.street_2 = address_to_copy_from[:street_2]
    self.street_3 = address_to_copy_from[:street_3]
    self.town     = address_to_copy_from[:town]
    self.postcode = address_to_copy_from[:postcode]
    self.save
  end

  def self.create_random
    self.create(generate)
  end

  def self.generate()

    address = {
      :street_1   => Random.address_line_1,
      :postcode   => Random.uk_post_code,
      :town       => Random.city
    }

    i = rand
    if i > 0.6
      address[:street_3] = Random.address_line_2
    elsif i > 0.2
      address[:street_2] = Random.address_line_2
    else
      address[:street_2] = Random.address_line_2
      address[:street_3] = Random.address_line_2
    end
    address[:county] = random_county if rand > 0.3
    address
  end

  def self.random_county
    uk_county_arrray = ['Bedfordshire', 'Berkshire', 'Bristol', 'Buckinghamshire', 'Cambridgeshire', 'Cheshire', 'City of London', 'Cornwall', 'Cumbria', 'Derbyshire', 'Devon', 'Dorset', 'Durham', 'East Riding of Yorkshire', 'East Sussex', 'Essex', 'Gloucestershire', 'Greater London', 'Greater Manchester', 'Hampshire', 'Herefordshire', 'Hertfordshire', 'Isle of Wight', 'Kent', 'Lancashire', 'Leicestershire', 'Lincolnshire', 'Merseyside', 'Norfolk', 'North Yorkshire', 'Northamptonshire', 'Northumberland', 'Nottinghamshire', 'Oxfordshire', 'Rutland', 'Shropshire', 'Somerset', 'South Yorkshire', 'Staffordshire', 'Suffolk', 'Surrey', 'Tyne and Wear', 'Warwickshire', 'West Midlands', 'West Sussex', 'West Yorkshire', 'Wiltshire', 'Worcestershire', 'Anglesey', 'Brecknockshire', 'Caernarfonshire', 'Carmarthenshire', 'Cardiganshire', 'Denbighshire', 'Flintshire', 'Glamorgan', 'Merioneth', 'Monmouthshire', 'Montgomeryshire', 'Pembrokeshire', 'Radnorshire', 'Aberdeenshire', 'Angus', 'Argyllshire', 'Ayrshire', 'Banffshire', 'Berwickshire', 'Buteshire', 'Cromartyshire', 'Caithness', 'Clackmannanshire', 'Dumfriesshire', 'Dunbartonshire', 'East Lothian', 'Fife', 'Inverness-shire', 'Kincardineshire', 'Kinross', 'Kirkcudbrightshire', 'Lanarkshire', 'Midlothian', 'Morayshire', 'Nairnshire', 'Orkney', 'Peeblesshire', 'Perthshire', 'Renfrewshire', 'Ross-shire', 'Roxburghshire', 'Selkirkshire', 'Shetland', 'Stirlingshire', 'Sutherland', 'West Lothian', 'Wigtownshire', 'Antrim', 'Armagh', 'Down', 'Fermanagh', 'Londonderry', 'Tyrone' ]
    uk_county_arrray.sample
  end
end
{'fraction_non_alphanumeric': 0.1408839779005525, 'fraction_numerical': 0.009821976672805401, 'mean_word_length': 5.035185185185185, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '5152637', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1148, 'n_words': 223}