1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
# 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
# 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
#
class ListDetectionsResponse
include Google::Apis::Core::Hashable
# A detections contains detection results of several text
# Corresponds to the JSON property `detections`
# @return [Array<Array<Google::Apis::TranslateV2::DetectionsResource>>]
attr_accessor :detections
def initialize(**args)
update!(**args)
end
# Update properties of this object
def update!(**args)
@detections = args[:detections] if args.key?(:detections)
end
end
#
class DetectionsResource
include Google::Apis::Core::Hashable
# The confidence of the detection result of this language.
# Corresponds to the JSON property `confidence`
# @return [Float]
attr_accessor :confidence
# 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
# The language we detected.
# Corresponds to the JSON property `language`
# @return [String]
attr_accessor :language
def initialize(**args)
update!(**args)
end
# Update properties of this object
def update!(**args)
@confidence = args[:confidence] if args.key?(:confidence)
@is_reliable = args[:is_reliable] if args.key?(:is_reliable)
@language = args[:language] if args.key?(:language)
end
end
# The request message for discovering supported languages.
class GetSupportedLanguagesRequest
include Google::Apis::Core::Hashable
# The language to use to return localized, human readable names of supported
# languages.
# Corresponds to the JSON property `target`
# @return [String]
attr_accessor :target
def initialize(**args)
update!(**args)
end
# 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
def initialize(**args)
update!(**args)
end
# Update properties of this object
def update!(**args)
@languages = args[:languages] if args.key?(:languages)
end
end
#
class LanguagesResource
include Google::Apis::Core::Hashable
# 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
def initialize(**args)
update!(**args)
end
# Update properties of this object
def update!(**args)
@language = args[:language] if args.key?(:language)
@name = args[:name] if args.key?(:name)
end
end
# The main translation request message for the Cloud Translation API.
class TranslateTextRequest
include Google::Apis::Core::Hashable
# 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`
# @return [String]
attr_accessor :format
# 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
# 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
# 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`
# @return [String]
attr_accessor :source
# 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`
# @return [String]
attr_accessor :target
def initialize(**args)
update!(**args)
end
# Update properties of this object
def update!(**args)
@format = args[:format] if args.key?(:format)
@model = args[:model] if args.key?(:model)
@q = args[:q] if args.key?(:q)
@source = args[:source] if args.key?(:source)
@target = args[:target] if args.key?(:target)
end
end
# The main language translation response message.
class ListTranslationsResponse
include Google::Apis::Core::Hashable
# Translations contains list of translation results of given text
# Corresponds to the JSON property `translations`
# @return [Array<Google::Apis::TranslateV2::TranslationsResource>]
attr_accessor :translations
def initialize(**args)
update!(**args)
end
# Update properties of this object
def update!(**args)
@translations = args[:translations] if args.key?(:translations)
end
end
#
class TranslationsResource
include Google::Apis::Core::Hashable
# 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`
# @return [String]
attr_accessor :detected_source_language
# 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`
# @return [String]
attr_accessor :model
# Text translated into the target language.
# Corresponds to the JSON property `translatedText`
# @return [String]
attr_accessor :translated_text
def initialize(**args)
update!(**args)
end
# Update properties of this object
def update!(**args)
@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)
end
end
end
end
end
|