Sha256: 8c324b3e74d9950282f3f110e4a891e529fc3cb2c4194587710f10a8d87e0e62
Contents?: true
Size: 692 Bytes
Versions: 1
Compression:
Stored size: 692 Bytes
Contents
#!/usr/bin/ruby BEGIN { $LOAD_PATH.unshift File::dirname(File::dirname( __FILE__ )) + "/lib" require 'linguistics' } Linguistics::use( :en, :installProxy => :en ) # Just a bit of fun -- takes a sentence, and tries to generalize it by looking # up the hypernyms of each of the words. This'll work much better when # integration with LinkParser is added, as this doesn't know about parts of # speech or anything. if ARGV.empty? print "Sentence: " sentence = $stdin.gets else sentence = ARGV.join(" ") end newSentence = sentence.split.collect {|word| word.hypernyms ? word.hypernyms[0].words[0] : word }.join(" ") puts "Converted:\n %s\nto\n %s\n\n" % [ sentence, newSentence ]
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eviltrout-linguistics-1.0.6.1 | experiments/generalize.rb |