module TextCleaner
Constants
- FILLER_WORDS
Public Class Methods
clean_text(text)
click to toggle source
# File lib/facebook_word_counter/text_cleaner.rb, line 2 def self.clean_text(text) text = remove_urls(text.downcase) text = remove_punctuation(text) text = remove_filler_words(text) text.strip end
remove_filler_words(text)
click to toggle source
# File lib/facebook_word_counter/text_cleaner.rb, line 18 def self.remove_filler_words(text) FILLER_WORDS.each do |word| text.gsub!(/ #{word} / , ' ') end text end
remove_punctuation(text)
click to toggle source
# File lib/facebook_word_counter/text_cleaner.rb, line 13 def self.remove_punctuation(text) text.gsub(/[^a-zA-Z\s]/, '') end
remove_urls(text)
click to toggle source
# File lib/facebook_word_counter/text_cleaner.rb, line 9 def self.remove_urls(text) text.gsub(/https?:\/\/[\S]+/, '') end