<commit_before>require "ordspel/version"

module Ordspel

  @@letter_o = "oóòŏôốồỗổǒöȫőõṍṏȭȯȱøǿǫǭōṓ̂ṑỏȍȏơớờỡởợọộɵｏꜵœꝏꝍȣ"
  @@letter_a = "aáàâǎăãảȧạåḁāąⱥȁấầẫẩậắằẵẳặǻǡǟȁȃɑɐａǽǣꜳꜵꜷꜹꜻ"
  @@letter_e = "eéèêḙěĕẽḛẻėëēȩęɇȅếềễểḝḗḕȇẹệｅæǽǣœ"
  @@consonants = "bcdfghjklmnpqrstvxz"
  @@vowels = "aeiouy"

  def swedify
    self.chars.map do |letter|
      case letter
        when /^[#{@@letter_o}]$/i
          letter = letter =~ /^[#{@@letter_o}]$/ ? "ö" : "Ö"
        when /^[#{@@letter_e}]$/i
          letter = letter =~ /^[#{@@letter_e}]$/ ? "ä" : "Ä"
        when /^[#{@@letter_a}]$/i
          letter = letter =~ /^[#{@@letter_a}]$/ ? "å" : "Å"
        else
          letter
      end
    end.join
  end

  def norwegify
    self.chars.map do |letter|
      case letter
        when /^[#{@@letter_o}]$/i
          letter = letter =~ /^[#{@@letter_o}]$/ ? "ø" : "Ø"
        when /^[#{@@letter_e}]$/i
          letter = letter =~ /^[#{@@letter_e}]$/ ? "æ" : "Æ"
        when /^[#{@@letter_a}]$/i
          letter = letter =~ /^[#{@@letter_a}]$/ ? "å" : "Å"
        else
          letter
      end
    end.join
  end

  alias_method :danify, :norwegify

  def spanify
    self.split(' ').map do |letter|
      if letter[-1] =~ /^[#{@@consonants}]$/
        letter + "o"
      else
        letter
      end
    end.join(' ')
  end

  def frenchify
    self.gsub(/\bh/i,'').split(' ').join(' euhhh ') + " euhhh"
  end

  def chinify
    self.chars.map do |letter|
      if letter =~ /^[l]$/i
        letter = letter =~ /^[l]$/ ? "r" : "R"
      else
        letter
      end
    end.join
  end

  def japanify
    "You bring dishonor to whole family."
  end

  def germanify
    string = self.split(" ").map { |word| word.capitalize }.join(' ')
    #in case first letters of string are th
    string[0..1] = "Z" if string[0..1] =~ /^th$/i
    string = "JA Zo, " + string
    string.gsub(/\sth/i, ' Z')
    string.chars.map do |letter|
      if letter =~ /^[u]$/i
        letter = letter =~ /^[u]$/ ? "ü" : "Ü"
      else
        letter
      end
    end.join
  end

  def russify
    self.chars.map do |letter|
      if letter =~ /^[w]$/i
        letter = letter =~ /^[w]$/ ? "v" : "V"
      else
        letter
      end
    end.join
  end

  def dutchify
    self.chars.map do |letter|
      if letter =~ /^[s]$/i
        letter = letter =~ /^[s]$/ ? "sh" : "Sh"
      else
        letter
      end
    end.join
  end

  def irishify
    "What's the craic? " + self.gsub(/\bMy\b/, 'Me').gsub(/\bmy\b/i, 'me')
  end

  def portugify
    self.gsub(/ce\b/i, 'ção').chars.map do |letter|
      case letter
        when /^[#{@@letter_a}]$/i
          letter = letter =~ /^[#{@@letter_a}]$/ ? "ã" : "Ã"
        when /^[c]$/i
          letter = letter =~ /^[c]$/ ? "ç" : "Ç"
        else
          letter
      end
    end.join
  end

  def swissify
    self.frenchify.germanify
  end

  def welshify
    self.chars.map do |letter|
      if letter =~ /^[#{@@vowels}]$/i
          letter = letter =~ /^[#{@@vowels}]$/ ? "y" : "Y"
      else
        letter
      end
    end.join
  end

  def belgify
     self.dutchify.frenchify
  end

end

class String
  include Ordspel
end


<commit_msg>Added canadian and american, updated swedish<commit_after>require "ordspel/version"

module Ordspel

  @@letter_o = "oóòŏôốồỗổǒöȫőõṍṏȭȯȱøǿǫǭōṓ̂ṑỏȍȏơớờỡởợọộɵｏꜵœꝏꝍȣ"
  @@letter_a = "aáàâǎăãảȧạåḁāąⱥȁấầẫẩậắằẵẳặǻǡǟȁȃɑɐａǽǣꜳꜵꜷꜹꜻ"
  @@letter_e = "eéèêḙěĕẽḛẻėëēȩęɇȅếềễểḝḗḕȇẹệｅæǽǣœ"
  @@consonants = "bcdfghjklmnpqrstvxz"
  @@vowels = "aeiouy"

  def swedify
    self.chars.map do |letter|
      case letter
        when /^[#{@@letter_o}]$/i
          letter = letter =~ /^[#{@@letter_o}]$/ ? "ö" : "Ö"
        when /^[#{@@letter_e}]$/i
          letter = letter =~ /^[#{@@letter_e}]$/ ? "ä" : "Ä"
        when /^[#{@@letter_a}]$/i
          letter = letter =~ /^[#{@@letter_a}]$/ ? "å" : "Å"
        when /^[w]$/i
          letter = letter =~ /^[w]$/ ? "w" : "W"
        else
          letter
      end
    end.join
  end

  def norwegify
    self.chars.map do |letter|
      case letter
        when /^[#{@@letter_o}]$/i
          letter = letter =~ /^[#{@@letter_o}]$/ ? "ø" : "Ø"
        when /^[#{@@letter_e}]$/i
          letter = letter =~ /^[#{@@letter_e}]$/ ? "æ" : "Æ"
        when /^[#{@@letter_a}]$/i
          letter = letter =~ /^[#{@@letter_a}]$/ ? "å" : "Å"
        when /^[w]$/i
          letter = letter =~ /^[w]$/ ? "w" : "W"
        else
          letter
      end
    end.join
  end

  alias_method :danify, :norwegify

  def spanify
    self.split(' ').map do |letter|
      if letter[-1] =~ /^[#{@@consonants}]$/
        letter + "o"
      else
        letter
      end
    end.join(' ')
  end

  def frenchify
    self.gsub(/\bh/i,'').split(' ').join(' euhhh ') + " euhhh"
  end

  def chinify
    self.chars.map do |letter|
      if letter =~ /^[l]$/i
        letter = letter =~ /^[l]$/ ? "r" : "R"
      else
        letter
      end
    end.join
  end

  def japanify
    "You bring dishonor to whole family."
  end

  def germanify
    string = self.split(" ").map { |word| word.capitalize }.join(' ')
    #in case first letters of string are th
    string[0..1] = "Z" if string[0..1] =~ /^th$/i
    string = "JA Zo, " + string
    string.gsub(/\sth/i, ' Z')
    string.chars.map do |letter|
      if letter =~ /^[u]$/i
        letter = letter =~ /^[u]$/ ? "ü" : "Ü"
      else
        letter
      end
    end.join
  end

  def russify
    self.chars.map do |letter|
      if letter =~ /^[w]$/i
        letter = letter =~ /^[w]$/ ? "v" : "V"
      else
        letter
      end
    end.join
  end

  def dutchify
    self.chars.map do |letter|
      if letter =~ /^[s]$/i
        letter = letter =~ /^[s]$/ ? "sh" : "Sh"
      else
        letter
      end
    end.join
  end

  def irishify
    "What's the craic? " + self.gsub(/\bMy\b/, 'Me').gsub(/\bmy\b/i, 'me')
  end

  def portugify
    self.gsub(/ce\b/i, 'ção').chars.map do |letter|
      case letter
        when /^[#{@@letter_a}]$/i
          letter = letter =~ /^[#{@@letter_a}]$/ ? "ã" : "Ã"
        when /^[c]$/i
          letter = letter =~ /^[c]$/ ? "ç" : "Ç"
        else
          letter
      end
    end.join
  end

  def swissify
    self.frenchify.germanify
  end

  def welshify
    self.chars.map do |letter|
      if letter =~ /^[#{@@vowels}]$/i
          letter = letter =~ /^[#{@@vowels}]$/ ? "y" : "Y"
      else
        letter
      end
    end.join
  end

  def belgify
     self.dutchify.frenchify
  end

  def americanify
    self.split(" ").join(' like ')
  end

  def canadify
    word_list = ["eh", "sorry", "bud", "crosby", "hockey"]
    self.split(" ").map do |word|
      "#{word} #{word_list.sample}"
    end.join(' ')
  end
end

class String
  include Ordspel
end



{'fraction_non_alphanumeric': 0.18610164468810195, 'fraction_numerical': 0.001481700992739665, 'mean_word_length': 1.8313758389261745, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2828210', 'n_tokens_mistral': 3024, 'n_tokens_neox': 2923, 'n_words': 601}