Class: LangTool::Checker

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/langtool/checker.rb

Class Method Summary collapse

Class Method Details

.check(text, language) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/langtool/checker.rb', line 5

def self.check(text, language)
  options = {
    body: {
      text: text,
      language: language
    }
  }

  response = HTTParty.post('https://languagetool.org/api/v2/check', options)
  return response.body if response.body.start_with?('Error')
  JSON.parse response.body, symbolize_names: true
end