Module: YandexCloud::Translate::Detect

Included in:
YandexCloud::Translate
Defined in:
lib/yandex_cloud/translate/detect.rb

Overview

Module for detecting language of the text

Instance Method Summary collapse

Instance Method Details

#detect(args = {}) ⇒ Object

Detect



6
7
8
9
10
11
12
# File 'lib/yandex_cloud/translate/detect.rb', line 6

def detect(args = {})
  # define params for request
  body = { 'folderId' => folder_id, 'hint' => args[:hint], 'text' => args[:text] }
  headers = { 'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => "Bearer #{iam_token}" }
  # make request
  self.class.post('/detect', query: body, headers: headers).parsed_response
end