Sha256: 3a6dd20a20aa26f73b191e18c1377c7ca1e7357edc9367e2c8fd2c93611463d6
Contents?: true
Size: 973 Bytes
Versions: 1
Compression:
Stored size: 973 Bytes
Contents
require 'jisho/version' require 'jisho/misspellings' module Jisho # Check text for misspelled words. # # misspellings = Jisho.check 'Thiis sentence has a misspelled word.' # misspellings.words # => ["Thiis"] # misspellings.first[:word] # => "Thiis" # misspellings.first[:row] # => 1 # misspellings.first[:column] # => 1 # misspellings.first[:suggestions] # => ["Thais", "This", "Thins"] def self.check(text) misspellings = Jisho::Misspellings.new result = IO.popen "hunspell -d en_us", 'r+' do |io| io.write text io.close_write io.read end row = 1 result.lines do |line| case line when '' row += 1 when /^\& (.*?) (\d+) (\d+): (.*)/ misspellings << { :word => $1, :row => row, :column => $3.to_i + 1, :suggestions => $4.split(', ') } end end misspellings end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jisho-0.1.1 | lib/jisho.rb |