Class: Google::Cloud::Translate::Translation

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/translate/translation.rb

Overview

Translation

Represents a translation query result. Returned by Api#translate.

Examples:

require "google/cloud/translate"

translate = Google::Cloud::Translate.new

translation = translate.translate "Hello world!", to: "la"

translation.to_s #=> "Salve mundi!"

translation.from #=> "en"
translation.origin #=> "Hello world!"
translation.to #=> "la"
translation.text #=> "Salve mundi!"

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fromString (readonly) Also known as: source

The source language from which the text was translated.

Returns:

  • (String)


69
70
71
# File 'lib/google/cloud/translate/translation.rb', line 69

def from
  @from
end

#modelString (readonly)

The translation model. Can be either base for the Phrase-Based Machine Translation (PBMT) model, or nmt for the Neural Machine Translation (NMT) model. If you did not include a model parameter with your request, then this field is not included in the response.

Returns:

  • (String)


79
80
81
# File 'lib/google/cloud/translate/translation.rb', line 79

def model
  @model
end

#originString (readonly)

The original query text that was translated.

Returns:

  • (String)


55
56
57
# File 'lib/google/cloud/translate/translation.rb', line 55

def origin
  @origin
end

#textString (readonly) Also known as: to_s, to_str

The translated result.

Returns:

  • (String)


47
48
49
# File 'lib/google/cloud/translate/translation.rb', line 47

def text
  @text
end

#toString (readonly) Also known as: language, target

The target language into which the text was translated.

Returns:

  • (String)


61
62
63
# File 'lib/google/cloud/translate/translation.rb', line 61

def to
  @to
end

Instance Method Details

#detected?Boolean

Determines if the source language was detected by the Google Cloud Cloud Translation API.

Returns:

  • (Boolean)

    true if the source language was detected by the Cloud Translation API, false if the source language was provided in the request



99
100
101
# File 'lib/google/cloud/translate/translation.rb', line 99

def detected?
  @detected
end