2015-06-23 23:05:46 +00:00
|
|
|
# Copyright 2015 Google Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
require 'date'
|
|
|
|
require 'google/apis/core/base_service'
|
|
|
|
require 'google/apis/core/json_representation'
|
|
|
|
require 'google/apis/core/hashable'
|
|
|
|
require 'google/apis/errors'
|
|
|
|
|
|
|
|
module Google
|
|
|
|
module Apis
|
|
|
|
module TranslateV2
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# The request message for language detection.
|
|
|
|
class DetectLanguageRequest
|
|
|
|
include Google::Apis::Core::Hashable
|
|
|
|
|
|
|
|
# The input text upon which to perform language detection. Repeat this
|
|
|
|
# parameter to perform language detection on multiple text inputs.
|
|
|
|
# Corresponds to the JSON property `q`
|
|
|
|
# @return [Array<String>]
|
|
|
|
attr_accessor :q
|
|
|
|
|
|
|
|
def initialize(**args)
|
|
|
|
update!(**args)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update properties of this object
|
|
|
|
def update!(**args)
|
|
|
|
@q = args[:q] if args.key?(:q)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-26 16:44:32 +00:00
|
|
|
#
|
2017-08-25 19:54:22 +00:00
|
|
|
class ListDetectionsResponse
|
2017-05-26 16:44:32 +00:00
|
|
|
include Google::Apis::Core::Hashable
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# A detections contains detection results of several text
|
|
|
|
# Corresponds to the JSON property `detections`
|
|
|
|
# @return [Array<Array<Google::Apis::TranslateV2::DetectionsResource>>]
|
|
|
|
attr_accessor :detections
|
2017-05-26 16:44:32 +00:00
|
|
|
|
|
|
|
def initialize(**args)
|
|
|
|
update!(**args)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update properties of this object
|
|
|
|
def update!(**args)
|
2017-08-25 19:54:22 +00:00
|
|
|
@detections = args[:detections] if args.key?(:detections)
|
2017-05-26 16:44:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-23 23:05:46 +00:00
|
|
|
#
|
2017-07-12 20:10:42 +00:00
|
|
|
class DetectionsResource
|
2015-06-23 23:05:46 +00:00
|
|
|
include Google::Apis::Core::Hashable
|
|
|
|
|
2017-07-12 20:10:42 +00:00
|
|
|
# The confidence of the detection result of this language.
|
|
|
|
# Corresponds to the JSON property `confidence`
|
|
|
|
# @return [Float]
|
|
|
|
attr_accessor :confidence
|
2015-06-23 23:05:46 +00:00
|
|
|
|
2017-07-12 20:10:42 +00:00
|
|
|
# A boolean to indicate is the language detection result reliable.
|
|
|
|
# Corresponds to the JSON property `isReliable`
|
|
|
|
# @return [Boolean]
|
|
|
|
attr_accessor :is_reliable
|
|
|
|
alias_method :is_reliable?, :is_reliable
|
2015-06-23 23:05:46 +00:00
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# The language we detected.
|
|
|
|
# Corresponds to the JSON property `language`
|
|
|
|
# @return [String]
|
|
|
|
attr_accessor :language
|
|
|
|
|
2015-06-23 23:05:46 +00:00
|
|
|
def initialize(**args)
|
|
|
|
update!(**args)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update properties of this object
|
|
|
|
def update!(**args)
|
2017-07-12 20:10:42 +00:00
|
|
|
@confidence = args[:confidence] if args.key?(:confidence)
|
|
|
|
@is_reliable = args[:is_reliable] if args.key?(:is_reliable)
|
2017-08-25 19:54:22 +00:00
|
|
|
@language = args[:language] if args.key?(:language)
|
2015-06-23 23:05:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# The request message for discovering supported languages.
|
|
|
|
class GetSupportedLanguagesRequest
|
2015-06-23 23:05:46 +00:00
|
|
|
include Google::Apis::Core::Hashable
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# The language to use to return localized, human readable names of supported
|
|
|
|
# languages.
|
|
|
|
# Corresponds to the JSON property `target`
|
2017-06-02 06:11:31 +00:00
|
|
|
# @return [String]
|
2017-08-25 19:54:22 +00:00
|
|
|
attr_accessor :target
|
2017-05-26 16:44:32 +00:00
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
def initialize(**args)
|
|
|
|
update!(**args)
|
|
|
|
end
|
2017-05-26 16:44:32 +00:00
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# Update properties of this object
|
|
|
|
def update!(**args)
|
|
|
|
@target = args[:target] if args.key?(:target)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
class ListLanguagesResponse
|
|
|
|
include Google::Apis::Core::Hashable
|
|
|
|
|
|
|
|
# List of source/target languages supported by the translation API. If target
|
|
|
|
# parameter is unspecified, the list is sorted by the ASCII code point order of
|
|
|
|
# the language code. If target parameter is specified, the list is sorted by the
|
|
|
|
# collation order of the language name in the target language.
|
|
|
|
# Corresponds to the JSON property `languages`
|
|
|
|
# @return [Array<Google::Apis::TranslateV2::LanguagesResource>]
|
|
|
|
attr_accessor :languages
|
2017-05-26 16:44:32 +00:00
|
|
|
|
|
|
|
def initialize(**args)
|
|
|
|
update!(**args)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update properties of this object
|
|
|
|
def update!(**args)
|
2017-08-25 19:54:22 +00:00
|
|
|
@languages = args[:languages] if args.key?(:languages)
|
2017-05-26 16:44:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
#
|
|
|
|
class LanguagesResource
|
2015-06-23 23:05:46 +00:00
|
|
|
include Google::Apis::Core::Hashable
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# Supported language code, generally consisting of its ISO 639-1
|
|
|
|
# identifier. (E.g. 'en', 'ja'). In certain cases, BCP-47 codes including
|
|
|
|
# language + region identifiers are returned (e.g. 'zh-TW' and 'zh-CH')
|
|
|
|
# Corresponds to the JSON property `language`
|
|
|
|
# @return [String]
|
|
|
|
attr_accessor :language
|
|
|
|
|
|
|
|
# Human readable name of the language localized to the target language.
|
|
|
|
# Corresponds to the JSON property `name`
|
|
|
|
# @return [String]
|
|
|
|
attr_accessor :name
|
2015-06-23 23:05:46 +00:00
|
|
|
|
|
|
|
def initialize(**args)
|
|
|
|
update!(**args)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update properties of this object
|
|
|
|
def update!(**args)
|
2017-08-25 19:54:22 +00:00
|
|
|
@language = args[:language] if args.key?(:language)
|
|
|
|
@name = args[:name] if args.key?(:name)
|
2015-06-23 23:05:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-26 16:44:32 +00:00
|
|
|
# The main translation request message for the Cloud Translation API.
|
|
|
|
class TranslateTextRequest
|
2015-06-23 23:05:46 +00:00
|
|
|
include Google::Apis::Core::Hashable
|
|
|
|
|
2017-05-26 16:44:32 +00:00
|
|
|
# The format of the source text, in either HTML (default) or plain-text. A
|
|
|
|
# value of "html" indicates HTML and a value of "text" indicates plain-text.
|
|
|
|
# Corresponds to the JSON property `format`
|
2015-06-23 23:05:46 +00:00
|
|
|
# @return [String]
|
2017-05-26 16:44:32 +00:00
|
|
|
attr_accessor :format
|
2015-06-23 23:05:46 +00:00
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# The `model` type requested for this translation. Valid values are
|
|
|
|
# listed in public documentation.
|
|
|
|
# Corresponds to the JSON property `model`
|
|
|
|
# @return [String]
|
|
|
|
attr_accessor :model
|
|
|
|
|
2017-07-12 20:10:42 +00:00
|
|
|
# The input text to translate. Repeat this parameter to perform translation
|
|
|
|
# operations on multiple text inputs.
|
|
|
|
# Corresponds to the JSON property `q`
|
|
|
|
# @return [Array<String>]
|
|
|
|
attr_accessor :q
|
|
|
|
|
2017-05-26 16:44:32 +00:00
|
|
|
# The language of the source text, set to one of the language codes listed in
|
|
|
|
# Language Support. If the source language is not specified, the API will
|
|
|
|
# attempt to identify the source language automatically and return it within
|
|
|
|
# the response.
|
|
|
|
# Corresponds to the JSON property `source`
|
2015-06-23 23:05:46 +00:00
|
|
|
# @return [String]
|
2017-05-26 16:44:32 +00:00
|
|
|
attr_accessor :source
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# The language to use for translation of the input text, set to one of the
|
|
|
|
# language codes listed in Language Support.
|
|
|
|
# Corresponds to the JSON property `target`
|
2017-05-26 16:44:32 +00:00
|
|
|
# @return [String]
|
2017-08-25 19:54:22 +00:00
|
|
|
attr_accessor :target
|
2017-05-26 16:44:32 +00:00
|
|
|
|
2015-06-23 23:05:46 +00:00
|
|
|
def initialize(**args)
|
|
|
|
update!(**args)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update properties of this object
|
|
|
|
def update!(**args)
|
2017-05-26 16:44:32 +00:00
|
|
|
@format = args[:format] if args.key?(:format)
|
2017-08-25 19:54:22 +00:00
|
|
|
@model = args[:model] if args.key?(:model)
|
2017-07-12 20:10:42 +00:00
|
|
|
@q = args[:q] if args.key?(:q)
|
2017-05-26 16:44:32 +00:00
|
|
|
@source = args[:source] if args.key?(:source)
|
2017-08-25 19:54:22 +00:00
|
|
|
@target = args[:target] if args.key?(:target)
|
2017-05-26 16:44:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# The main language translation response message.
|
|
|
|
class ListTranslationsResponse
|
2017-05-26 16:44:32 +00:00
|
|
|
include Google::Apis::Core::Hashable
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# Translations contains list of translation results of given text
|
|
|
|
# Corresponds to the JSON property `translations`
|
|
|
|
# @return [Array<Google::Apis::TranslateV2::TranslationsResource>]
|
|
|
|
attr_accessor :translations
|
2017-05-26 16:44:32 +00:00
|
|
|
|
|
|
|
def initialize(**args)
|
|
|
|
update!(**args)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update properties of this object
|
|
|
|
def update!(**args)
|
2017-08-25 19:54:22 +00:00
|
|
|
@translations = args[:translations] if args.key?(:translations)
|
2015-06-23 23:05:46 +00:00
|
|
|
end
|
|
|
|
end
|
2017-07-12 20:10:42 +00:00
|
|
|
|
|
|
|
#
|
2017-08-25 19:54:22 +00:00
|
|
|
class TranslationsResource
|
2017-07-12 20:10:42 +00:00
|
|
|
include Google::Apis::Core::Hashable
|
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# The source language of the initial request, detected automatically, if
|
|
|
|
# no source language was passed within the initial request. If the
|
|
|
|
# source language was passed, auto-detection of the language will not
|
|
|
|
# occur and this field will be empty.
|
|
|
|
# Corresponds to the JSON property `detectedSourceLanguage`
|
2017-07-12 20:10:42 +00:00
|
|
|
# @return [String]
|
2017-08-25 19:54:22 +00:00
|
|
|
attr_accessor :detected_source_language
|
2017-07-12 20:10:42 +00:00
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# The `model` type used for this translation. Valid values are
|
|
|
|
# listed in public documentation. Can be different from requested `model`.
|
|
|
|
# Present only if specific model type was explicitly requested.
|
|
|
|
# Corresponds to the JSON property `model`
|
2017-07-12 20:10:42 +00:00
|
|
|
# @return [String]
|
2017-08-25 19:54:22 +00:00
|
|
|
attr_accessor :model
|
2017-07-12 20:10:42 +00:00
|
|
|
|
2017-08-25 19:54:22 +00:00
|
|
|
# Text translated into the target language.
|
|
|
|
# Corresponds to the JSON property `translatedText`
|
2017-07-12 20:10:42 +00:00
|
|
|
# @return [String]
|
2017-08-25 19:54:22 +00:00
|
|
|
attr_accessor :translated_text
|
2017-07-12 20:10:42 +00:00
|
|
|
|
|
|
|
def initialize(**args)
|
|
|
|
update!(**args)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update properties of this object
|
|
|
|
def update!(**args)
|
2017-08-25 19:54:22 +00:00
|
|
|
@detected_source_language = args[:detected_source_language] if args.key?(:detected_source_language)
|
|
|
|
@model = args[:model] if args.key?(:model)
|
|
|
|
@translated_text = args[:translated_text] if args.key?(:translated_text)
|
2017-07-12 20:10:42 +00:00
|
|
|
end
|
|
|
|
end
|
2015-06-23 23:05:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|