Skip to content

Getting the list of related words of a specific word using some 3rd services

License

Notifications You must be signed in to change notification settings

lmduc/related_word

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RelatedWord

Get the list of related words of a specific word.

Versions

For installations and instructions of older versions, please follow below links:

Installation

Add this line to your application's Gemfile:

gem 'related_word'

And then execute:

$ bundle

Or install it yourself as:

$ gem install related_word

Config

The code for config below is optional. For Rails, you can put those code in the file config/initializers/related_word.rb. For the pure Ruby, you can run those code whenever you want to set the config for the gem.

RelatedWord.config do |c|
  # Set the service serving the related word
  # The services is one of [:onelook, :semantic]
  # The default service is :semantic
  c.service = :onelook

  # The timeout for each request to the service
  # The default timeout is 2000
  c.timeout = 2000
end

Usage

RelatedWord.find

require 'related_word'

word = 'student'

r = RelatedWord.new # The default service is :semantic
r.find(word)
#=> [{:word=>"individualized", :score=>"0.258894"}, {:word=>"NUS", :score=>"0.206925"}, {:word=>"extracurricular", :score=>"0.206289"}, {:word=>"Yearbook", :score=>"0.197864"}, ...]


r = RelatedWord.new(:onelook) # Use the service :onelook
r.find(word)
#=> [{:word=>"academy", :score=>0}, {:word=>"grade", :score=>0}, {:word=>"seminary", :score=>0}, {:word=>"college", :score=>0}, {:word=>"graduate", :score=>0}, ...]

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/related_word. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

About

Getting the list of related words of a specific word using some 3rd services

Resources

License

Stars

Watchers

Forks

Packages

No packages published