lib/twexicon/analyzer.rb in twexicon-0.1.7.1 vs lib/twexicon/analyzer.rb in twexicon-0.1.8

- old
+ new

@@ -11,11 +11,11 @@ def run quit = false until quit @input = nil @int = "" - puts "What would you like to do next? For options, type 'help'." + puts "\nWhat would you like to do next? For options, type 'help'." until is_valid? @input = gets.strip.gsub(/\W/, "").downcase end case input when "help", "h" @@ -67,18 +67,20 @@ end puts "\n@#{username} said: #{tweets[int.to_i].keys[0]}" end end - # 38 words from https://en.wikipedia.org/wiki/Most_common_words_in_English –– Left out some common yet still interesting ones (People, Good, Think, Work, First, One, Two, Want, New, Give, Know) + # Words from https://en.wikipedia.org/wiki/Most_common_words_in_English –– Left out some common yet still interesting ones (People, Good, Think, Work, First, One, Two, Want, New, Give, Know) COMMON_WORDS = ["A", "About", "An", "And", "Are", "As", "At", "Be", "Been", "But", "By", "For", "From", "Get", "Had", "Has", "Have", "In", "Into", "Is", "It", "It's", "Its", "Just", "Not", "Of", "On", "Or", "Say", "So", "Some", "That", "The", "There", "These", "This", "Those", "To", "Up", "With", "I", "My", "Your", "They", "He", "You", "Do", "His", "We", "Her", "She", "Will", "All", "Would", "Their", "What", "Out", "If", "Who", "Which", "Go", "Me", "When", "Make", "Can", "Time", "No", "Him", "Take", "Year", "Could", "Them", "See", "Other", "Than", "Then", "Now", "Look", "Only", "Come", "Over", "Also", "Back", "After", "Use", "How", "Our", "Well", "Way", "Even", "Because", "Any", "Day", "Most", "Us", # other additions - "Wouldn't", "Couldn't", "Shouldn't", "Mustn't", "Would've", "Could've", "Should've", "Must've", "Hadn't", "Wasn't", "Weren't", "Ain't", "Aint", "Here", "Seem", "Seems", "That's", "Took", "Much", "More", "You're", "We're", "We've", "I've", "I'm", + "Wouldn't", "Couldn't", "Shouldn't", "Mustn't", "Would've", "Could've", "Should've", "Must've", "Hadn't", "Wasn't", "Weren't", "Ain't", "Aint", "Here", "Seem", "Seems", "That's", "Took", "Much", "More", "You're", "We're", "We've", "I've", "I'm", "Don't", "Got", "Soon", # contraction endings until I fix the parsing error "Re", "Ll", "Ve", # Letters until I fix the contraction parsing error - "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] + "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", + # Common words in other languages that *aren't* uncommon English words (so, "Con" doesn't count) + "En"] def get_words words = {} word_array = [] tweets.each_value do |v| # Count up instances of each word @@ -91,18 +93,20 @@ end end end words.each do |w, n| # Create strings for the words that occur >1 times case n - when 1..9 then word_array << "0#{n}x #{w}" - when 10..99 then word_array << "#{n}x #{w}" + when 1..9 then word_array << "000#{n}x #{w}" + when 10..99 then word_array << "00#{n}x #{w}" + when 100..999 then word_array << "0#{n}x #{w}" + when 1000..9999 then word_array << "#{n}x #{w}" end end if word_array.empty? puts "\nIt appears that @#{username} is not much of a talker." else puts "\n@#{username}'s current favorite word(s):" - puts word_array.sort.reverse.take(10) + puts word_array.sort.reverse.each{|w| w.sub!(/^0+/, "")}.take(10) end end def get_shouts collection = []