instance method find_synonyms

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18 Private

Available in: v2.2.3 v2.3.18

Signature

find_synonyms(word)

Look up synonyms on WordNet. Thanks to Florian Gross (flgr).

Parameters

word req
Source
# File railties/lib/rails_generator/commands.rb, line 412
          def find_synonyms(word)
            require 'open-uri'
            require 'timeout'
            timeout(5) do
              open(SYNONYM_LOOKUP_URI % word) do |stream|
                # Grab words linked to dictionary entries as possible synonyms
                data = stream.read.gsub("&nbsp;", " ").scan(/<a href="webwn.*?">([\w ]*?)<\/a>/s).uniq
              end
            end
          rescue Exception
            return nil
          end

Defined in railties/lib/rails_generator/commands.rb line 412 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Rails::Generator::Commands::Create

Type at least 2 characters to search.

↑↓ navigate · open · esc close