Sha256: cbf6aef3f16a7d405de03b0282c31769156e21db1b52dd00877baeadf488bb50

Contents?: true

Size: 581 Bytes

Versions: 1

Compression:

Stored size: 581 Bytes

Contents

module TypoGen
  class EndSameSound
    PATTERN_LIST = [
        %w(ar er),
        %w(ll le),
        %w(se ce),
        %w(sion tion),
        %w(tar tor ter),
        %w(ser cer),
        %w(val vel)
    ]

    def self.create(word)
      typo_list = []

      PATTERN_LIST.each do |pattern|
        pattern.combination(2).each do |from, to|
          if word =~ /#{from}$/
            typo_list << word.sub(/#{from}$/, to)
          elsif word =~ /#{to}$/
            typo_list << word.sub(/#{to}$/, from)
          end
        end
      end

      typo_list
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typogen-0.1.0 lib/typogen/end_same_sound.rb