<commit_before>def require_gem_with_feedback(gem)
  begin
    require gem
  rescue LoadError
    puts "You need to 'sudo gem install #{gem}' before we can proceed"
  end
end

class String
  def wiki_linked
    self.gsub!(  /([A-Z][a-z]+[A-Z][A-Za-z0-9]+)/  ) do |page| # simple WikiWords
      class_not_found = (Page.new(page).tracked?) ? "" : %{class="notfound"}
      %{<a #{class_not_found} href="/#{page}">#{page}</a>}
    end

    self.gsub!(  /\[\[[^\]]+\]\]/  ) do |page_wbrackets| # simple [[any words between double brackets]]
      page = page_wbrackets[2..-3] # remove outer two brackets
      class_not_found = (Page.new(page).tracked?) ? "" : %{class="notfound"}
      %{<a #{class_not_found} href="/#{page.wiki_filename}">#{page}</a>}
    end
    self
  end

  # convert to a filename (substitute _ for spaces)
  def wiki_filename
    self.gsub( ' ', '_' )
  end

  # unconvert filename into title (substitute spaces for _)
  def unwiki_filename
    self.gsub( '_', ' ' )
  end
end

class Time
  def for_time_ago_in_words
    "#{(self.to_i * 1000)}"
  end
end
<commit_msg>refine bracketed wiki word regex, limiting to word chars, spaces, underscores, and dashes<commit_after>def require_gem_with_feedback(gem)
  begin
    require gem
  rescue LoadError
    puts "You need to 'sudo gem install #{gem}' before we can proceed"
  end
end

class String
  def wiki_linked
    self.gsub!(  /([A-Z][a-z]+[A-Z][A-Za-z0-9]+)/  ) do |page| # simple WikiWords
      class_not_found = (Page.new(page).tracked?) ? "" : %{class="notfound"}
      %{<a #{class_not_found} href="/#{page}">#{page}</a>}
    end

    self.gsub!(  /\[\[([A-Za-z0-9_ -])+\]\]/  ) do |page_wbrackets| # simple [[any words between double brackets]]
      page = page_wbrackets[2..-3] # remove outer two brackets
      class_not_found = (Page.new(page).tracked?) ? "" : %{class="notfound"}
      %{<a #{class_not_found} href="/#{page.wiki_filename}">#{page}</a>}
    end
    self
  end

  # convert to a filename (substitute _ for any whitespace)
  def wiki_filename
    self.gsub( /\s/, '_' )
  end

  # unconvert filename into title (substitute spaces for _)
  def unwiki_filename
    self.gsub( '_', ' ' )
  end
end

class Time
  def for_time_ago_in_words
    "#{(self.to_i * 1000)}"
  end
end

{'fraction_non_alphanumeric': 0.1647577092511013, 'fraction_numerical': 0.007929515418502203, 'mean_word_length': 3.236940298507463, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4065570', 'n_tokens_mistral': 874, 'n_tokens_neox': 833, 'n_words': 201}