Class: TypoGen::EndSameSound

Inherits:
Object
  • Object
show all
Defined in:
lib/typogen/end_same_sound.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.create(word) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/typogen/end_same_sound.rb', line 14

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