diff --git a/extract_poems.rb b/extract_poems.rb index bffaa73..e7072cd 100644 --- a/extract_poems.rb +++ b/extract_poems.rb @@ -7,7 +7,7 @@ MIN_8S = 5 def expand(set) cased = set + set.map(&:downcase) + set.map(&:upcase) spaced = cased + cased.map { _1.gsub(/\s/, ' ') } + cased.map { _1.gsub(/\s/, "\n") } + cased.flat_map do |amulet| - 20.times.map { amulet.gsub(/\s/) { rand(2).zero? ? ' ' : "\n" } } + 100.times.map { amulet.gsub(/\s/) { rand(2).zero? ? ' ' : "\n" } } end spaced + spaced.flat_map { _1.match?(/[.?!]$/) ? [_1.gsub('.', '?'), _1.gsub('?', '.')] : ["#{_1}.", "#{_1}?"] } end