Class: Google::Cloud::Translate::Detection
- Inherits:
-
Object
- Object
- Google::Cloud::Translate::Detection
- Defined in:
- lib/google/cloud/translate/detection.rb
Overview
Detection
Represents a detect language query result. Returned by Api#detect.
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#results ⇒ Array<Detection::Result>
readonly
The list of detection results for the given text.
-
#text ⇒ String
readonly
The text upon which the language detection was performed.
Instance Method Summary collapse
-
#confidence ⇒ Float
The confidence that the language detection result is correct.
-
#language ⇒ String
The most likely language that was detected.
Instance Attribute Details
#results ⇒ Array<Detection::Result> (readonly)
The list of detection results for the given text. The most likely language is listed first, and its attributes can be accessed through #language and #confidence.
56 57 58 |
# File 'lib/google/cloud/translate/detection.rb', line 56 def results @results end |
#text ⇒ String (readonly)
The text upon which the language detection was performed.
48 49 50 |
# File 'lib/google/cloud/translate/detection.rb', line 48 def text @text end |
Instance Method Details
#confidence ⇒ Float
The confidence that the language detection result is correct. The closer this value is to 1, the higher the confidence in language detection.
71 72 73 74 |
# File 'lib/google/cloud/translate/detection.rb', line 71 def confidence return nil if results.empty? results.first.confidence end |
#language ⇒ String
The most likely language that was detected. This is an ISO 639-1 language code.
82 83 84 85 |
# File 'lib/google/cloud/translate/detection.rb', line 82 def language return nil if results.empty? results.first.language end |