Skip to content

Instantly share code, notes, and snippets.

@nerdyworm
Created April 30, 2011 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerdyworm/949700 to your computer and use it in GitHub Desktop.
Save nerdyworm/949700 to your computer and use it in GitHub Desktop.
Silly list based noun finder
class String
@@nouns = []
def is_noun?
String.nouns.include? self.downcase
end
def find_nouns
self.split(/\s/).collect { |w| w if w.is_noun? }.compact
end
def self.nouns
if @@nouns.empty?
File.open('nouns_list.txt','r') do |f|
f.each_line do |line|
@@nouns.push line.strip.downcase
end
end
end
@@nouns
end
end
input = IO.read('input.txt')
puts input.to_s.find_nouns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment