Permalink
Browse files

Resurrect WordNet synonym lookups. Closes #10710.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8615 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
jeremy committed Jan 10, 2008
1 parent f05b870 commit 3642a4d6f88d774b56cf82d111179c1743065015
Showing with 5 additions and 3 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +3 −3 railties/lib/rails_generator/commands.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Resurrect WordNet synonym lookups. #10710 [tom./, matt]
+
* Added config.cache_store to environment options to control the default cache store (default is FileStore if tmp/cache is present, otherwise MemoryStore is used) [DHH]
* Added that rails:update is run when you do rails:freeze:edge to ensure you also get the latest JS and config files #10565 [jeff]
@@ -391,16 +391,16 @@ def raise_class_collision(class_name)
raise UsageError, message
end
- SYNONYM_LOOKUP_URI = "http://wordnet.princeton.edu/cgi-bin/webwn2.0?stage=2&word=%s&posnumber=1&searchtypenumber=2&senses=&showglosses=1"
+ SYNONYM_LOOKUP_URI = "http://wordnet.princeton.edu/perl/webwn?s=%s"
# Look up synonyms on WordNet. Thanks to Florian Gross (flgr).
def find_synonyms(word)
require 'open-uri'
require 'timeout'
timeout(5) do
open(SYNONYM_LOOKUP_URI % word) do |stream|
- data = stream.read.gsub("&nbsp;", " ").gsub("<BR>", "")
- data.scan(/^Sense \d+\n.+?\n\n/m)
+ # 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

0 comments on commit 3642a4d

Please sign in to comment.