Sha256: 9ae82d19b6f7c98e48b5aea99dc8980f3578ea5fa97739246dfc8b5c818d1c9f

Contents?: true

Size: 614 Bytes

Versions: 3

Compression:

Stored size: 614 Bytes

Contents

module TypoGen
  class EndSameSound
    PATTERN_LIST = [
        %w(dar der),
        %w(se ce),
        %w(sion tion),
        %w(tar tor ter),
        %w(ser cer),
        %w(val vel),
        %w(rize lize),
        %w(ry ly),
    ].freeze

    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

3 entries across 3 versions & 1 rubygems

Version Path
typogen-0.2.2 lib/typogen/end_same_sound.rb
typogen-0.2.1 lib/typogen/end_same_sound.rb
typogen-0.2.0 lib/typogen/end_same_sound.rb