From 3e6ae45a93a6f46980a01d3637406649dbc937b8 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Mon, 7 Mar 2016 22:09:30 -0300 Subject: [PATCH] Handle Capitalize too Handles capitalize too, using the same lib --- lib/text_cleaner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/text_cleaner.rb b/lib/text_cleaner.rb index 656fba28f05..1b0659cb0d6 100644 --- a/lib/text_cleaner.rb +++ b/lib/text_cleaner.rb @@ -31,9 +31,9 @@ class TextCleaner # Replace ????? with a single ? text.gsub!(/\?+/, '?') if opts[:deduplicate_question_marks] # Replace all-caps text with regular case letters - text = text.mb_chars.downcase if opts[:replace_all_upper_case] && (text =~ /[A-Z]+/) && (text == text.upcase) + text = text.mb_chars.downcase.to_s if opts[:replace_all_upper_case] && (text =~ /[A-Z]+/) && (text == text.upcase) # Capitalize first letter, but only when entire first word is lowercase - text.sub!(/\A([a-z]*)\b/) { |first| first.capitalize } if opts[:capitalize_first_letter] + text = text.mb_chars.capitalize.to_s if opts[:capitalize_first_letter] && text.split(' ').first == text.split(' ').first.mb_chars.downcase # Remove unnecessary periods at the end text.sub!(/([^.])\.+(\s*)\z/, '\1\2') if opts[:remove_all_periods_from_the_end] # Remove extraneous space before the end punctuation