Spell Check in ruby and rails using BOSSMan

Wrong English is an often problem while developing any website product asit gives bad view to website user and thus does direct impact on product.BOSSMan is a ruby gem that interacts with yahoo web service and provides asimplest way to overcome such errors.
Installation:
gem sources -a http://gems.github.comgem install jpignata-bossmanApply and get Application ID from yahoo developer networkURl https://developer.apps.yahoo.com/Make sure to note it for reference
Usage in ruby app
require 'rubygems'require 'bossman'include BOSSManBOSSMan.application_id = "Your Application ID here"
Spelling Suggestions
text = BOSSMan::Search.spelling("gooogle")=> #{"resultset_spell"=>[{"suggestion"=>"google"}], "responsecode"=>"200", "deephits"=>"1", "start"=>"0", "count"=>"1", "totalhits"=>"1"}}>text.suggestion => "google"
More sophisticated way of use –
1. Create a YML file containing list of kewords
2. Load YML file
3. Iterate YML hash to find out spell suggestions
Example: spelling.yml
1 keywords: 2 gooogle: 3 Barack Oabama: 4 Indian: 5 Latuur:
keywords = YAML.load_file('spelling.yml')['keywords'].keys puts "Correction suggested" keywords.each do |keyword| text = BOSSMan::Search.spelling(keyword) if defined? text.suggestion puts "#{keyword} => #{text.suggestion}" end end
Output
Correction suggestedgooogle => googleBarack Oabama => Barack ObamaLatuur => Latour
Analyze suggestions manually and make neccesary corrections..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.