module SimpleSpeller
Constants
- SERVICE_URL
- VERSION
Public Class Methods
check(text, options = {})
click to toggle source
# File lib/simple_speller.rb, line 8 def self.check(text, options = {}) response = HTTParty.post(SERVICE_URL + CGI.escape(text), body: { lang: options[:lang] || 'ru,en', format: 'pain', options: 518 }.to_json, headers: { 'Content-Type' => 'application/json' }) JSON.parse response.body end
fix(text, options = {})
click to toggle source
# File lib/simple_speller.rb, line 17 def self.fix(text, options = {}) t = text.dup check(text, options).each do |ehash| start_i = ehash['pos'] end_i = start_i + ehash['len'] - 1 t[start_i..end_i] = ehash['s'].first end t end