Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8190751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:44:42+00:00 2026-06-07T03:44:42+00:00

I am looking for a relatively quick way to check whether words are misspelled,

  • 0

I am looking for a relatively quick way to check whether words are misspelled, either using a gem or API.

I’ve tried using several gems — raspell, ffi-aspell, hunspell-ffi, spell_cheker, and spellchecker — and each has a different error.

I’m pretty new to ruby and hoping for a simple solution (I’m processing a lot of short text files and want to calculate the % of words mis-spelled) that doesn’t include building something from scratch.

When trying ffi-aspell, I get the following error:

/Users/ntaylorthompson/.rvm/gems/ruby-1.9.2-p320/gems/ffi-aspell-0.0.3/lib/ffi/aspell/speller.rb:121: [BUG] Segmentation fault
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin11.4.0]

-- control frame ----------
c:0005 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC  :speller_check
c:0004 p:0113 s:0013 b:0013 l:000012 d:000012 METHOD /Users/ntaylorthompson/.rvm/gems/ruby-1.9.2-p320/gems/ffi-aspell-0.0.3/lib/ffi/aspell/speller.rb:121
c:0003 p:0049 s:0007 b:0007 l:0005a8 d:0005d0 EVAL   ffi-aspell_test.rb:5
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0005a8 d:0005a8 TOP   
---------------------------
-- Ruby level backtrace information ----------------------------------------
ffi-aspell_test.rb:5:in `<main>'
/Users/ntaylorthompson/.rvm/gems/ruby-1.9.2-p320/gems/ffi-aspell-0.0.3/lib/ffi/aspell/speller.rb:121:in `correct?'
/Users/ntaylorthompson/.rvm/gems/ruby-1.9.2-p320/gems/ffi-aspell-0.0.3/lib/ffi/aspell/speller.rb:121:in `speller_check'

-- C level backtrace information -------------------------------------------

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap: 6

I’d appreciate either (1) a suggestion of an alternative approach to those above or (2) a recommendation of which to use of the 5 gems above — so I can at least spend time debugging the best option.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:44:43+00:00Added an answer on June 7, 2026 at 3:44 am

    raspell is no longer maintained, so ffi-aspell is a good option if you have the libaspell headers available.

    If you can’t get the libraries to work, you can just shell out to the aspell binary. The following method will do just that (unit tests included):

    # Returns the percentage of incorrect words per document
    #
    def spellcheck(filename)
      fail "File #{filename} does not exist" unless File.exists?(filename)
    
      words = Float(`wc -w #{filename}`.split.first)
      wrong = Float(`cat #{filename} | aspell --list | wc -l`.split.first)
    
      wrong / words
    end
    
    if $0 == __FILE__
      require 'minitest/autorun'
      require 'tempfile'
    
      describe :spellcheck do
        def write(str)
          @file.write str
          @file.read
        end
    
        before do
          @file = Tempfile.new('document')
        end
    
        it 'fails when given a bad path' do
          -> { spellcheck('/tmp/does/not/exist') }.must_raise RuntimeError
        end
    
        it 'returns 0.0 if there are no misspellings' do
          write 'The quick brown fox'
          spellcheck(@file.path).must_equal 0.0
        end
    
        it 'returns 0.5 if 2/4 words are misspelled' do
          write 'jumped over da lacie'
          spellcheck(@file.path).must_be_close_to 0.5, 1e-8
        end
    
        it 'returns 1.0 if everything is misspelled' do
          write 'Da quyck bown foxx jmped oer da lassy dogg'
          spellcheck(@file.path).must_equal 1.0, 1e-8
        end
    
        after do
          @file.close
          @file.unlink
        end
      end
    end
    

    spellcheck() assumes you have cat, wc, and aspell on your path, and that the default dictionary is what you want to use. The unit test is for Ruby 1.9 only — if you’re running 1.8, just delete it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a relatively simpler (when compared with writing a parser) way to
What is a relatively quick and easy method of looking up what an arbitrary
I am relatively new to the whole MVC way of looking at things. I
I am looking for a simple way (web service, API call, etc.) to simply
I'm looking to make a relatively simple game using solely graphics primitives (Arcs, Lines,
I am looking for a way to condense relatively small areas of text on
I'm relatively new to animations so I'm looking for a bit of direction. Let's
I am looking for a suitable algorithm to build a relatively small (up to
I have a relatively simple algorithm that walks an std::vector looking for two neighbouring
I am relatively new to Android, but I am looking to use an interactive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.