<commit_before># encoding: utf-8

class AutolinkFilter < Filter

  def process(post)
    post.gsub(/(^|\s)((ftp|https?):\/\/[^\s]+\b\/?)/) do
      space, match = $1, $2
      uri = URI.extract($2).try(:first)
      space + match.gsub(uri, autolink(uri))
    end
  end

  private

  def autolink(url)
    if url =~ /\.(jpg|jpeg|gif|png)$/i
      "<img src=\"#{url}\">"<commit_msg>added autoembeding for imgur gifv links<commit_after># encoding: utf-8

class AutolinkFilter < Filter

  def process(post)
    post.gsub(/(^|\s)((ftp|https?):\/\/[^\s]+\b\/?)/) do
      space, match = $1, $2
      uri = URI.extract($2).try(:first)
      space + match.gsub(uri, autolink(uri))
    end
  end

  private

  def autolink(url)
    if url =~ /\.(jpg|jpeg|gif|png)$/i
      "<img src=\"#{url}\">"
    elsif url =~ /\.(gifv)$/i
      "<video loop controls autoplay><source src=\"" + url.sub(/\.gifv/, '.mp4') + "\" type=\"video/mp4\"></video>"
{'fraction_non_alphanumeric': 0.2317596566523605, 'fraction_numerical': 0.01072961373390558, 'mean_word_length': 2.6877470355731226, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 8, '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': '7563769', 'n_tokens_mistral': 379, 'n_tokens_neox': 368, 'n_words': 73}