<commit_before># A Document
#
# Can either be linked by a URL or attached from Google Docs.
#
# Evidence is associated with a Document Descriptor
class Document < ActiveRecord::Base
  include AuthoredModel
  VALID_SCHEMES = ['http', 'https']

  validate :link do
    begin
      if link.nil? || VALID_SCHEMES.include?(link.scheme)
        true
      else
        errors.add(:link, "scheme must be one of #{VALID_SCHEMES.join(', ')}")
      end
    rescue
      errors.add(:link, "must be a valid URI")
    end
  end

  belongs_to :document_descriptor

  validates :link,
    :uniqueness => true, :allow_blank => true, :presence => true

  def display_name
    title
  end

  def link
    link = read_attribute(:link)
    URI(link) if !link.blank?<commit_msg>Fix document to not die on bad URI already in the DB<commit_after># A Document
#
# Can either be linked by a URL or attached from Google Docs.
#
# Evidence is associated with a Document Descriptor
class Document < ActiveRecord::Base
  include AuthoredModel
  VALID_SCHEMES = ['http', 'https']

  validate :link do
    begin
      if link.nil? || VALID_SCHEMES.include?(link.scheme)
        true
      else
        errors.add(:link, "scheme must be one of #{VALID_SCHEMES.join(', ')}")
      end
    rescue
      errors.add(:link, "must be a valid URI")
    end
  end

  belongs_to :document_descriptor

  validates :link,
    :uniqueness => true, :allow_blank => true, :presence => true

  def display_name
    title
  end

  def link
    link = read_attribute(:link)
    URI(link) if !link.blank?
  rescue
    link
{'fraction_non_alphanumeric': 0.09663064208518754, 'fraction_numerical': 0.0, 'mean_word_length': 2.99492385786802, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3587438', 'n_tokens_mistral': 506, 'n_tokens_neox': 498, 'n_words': 166}