The confidence that the language detection result is correct. The closer this value is to 1, the higher the
confidence in language detection.
Returns
(Float) — a value between 0 and 1
#language
deflanguage()->String
The most likely language that was detected. This is an ISO
639-1 language code.
Returns
(String) — the language code
#results
defresults()->Array<Detection::Result>
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Translation V2 API - Class Google::Cloud::Translate::V2::Detection (v1.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.1.0 (latest)](/ruby/docs/reference/google-cloud-translate-v2/latest/Google-Cloud-Translate-V2-Detection)\n- [1.0.1](/ruby/docs/reference/google-cloud-translate-v2/1.0.1/Google-Cloud-Translate-V2-Detection)\n- [0.5.1](/ruby/docs/reference/google-cloud-translate-v2/0.5.1/Google-Cloud-Translate-V2-Detection)\n- [0.4.1](/ruby/docs/reference/google-cloud-translate-v2/0.4.1/Google-Cloud-Translate-V2-Detection)\n- [0.3.1](/ruby/docs/reference/google-cloud-translate-v2/0.3.1/Google-Cloud-Translate-V2-Detection) \nReference documentation and code samples for the Cloud Translation V2 API class Google::Cloud::Translate::V2::Detection.\n\nDetection\n---------\n\nRepresents a detect language query result. Returned by [Api#detect](/ruby/docs/reference/google-cloud-translate-v2/latest/Google-Cloud-Translate-V2-Api#Google__Cloud__Translate__V2__Api_detect_instance_ \"Google::Cloud::Translate::V2::Api#detect (method)\"). \n\nInherits\n--------\n\n- Object\n\nExample\n-------\n\n```ruby\nrequire \"google/cloud/translate/v2\"\n\ntranslate = Google::Cloud::Translate::V2.new\n\ndetections = translate.detect \"chien\", \"chat\"\n\ndetections.size #=\u003e 2\ndetections[0].text #=\u003e \"chien\"\ndetections[0].language #=\u003e \"fr\"\ndetections[0].confidence #=\u003e 0.7109375\ndetections[1].text #=\u003e \"chat\"\ndetections[1].language #=\u003e \"en\"\ndetections[1].confidence #=\u003e 0.59922177\n```\n\nMethods\n-------\n\n### #confidence\n\n def confidence() -\u003e Float\n\nThe confidence that the language detection result is correct. The closer this value is to 1, the higher the\nconfidence in language detection. \n**Returns**\n\n- (Float) --- a value between 0 and 1\n\n### #language\n\n def language() -\u003e String\n\nThe most likely language that was detected. This is an [ISO\n639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code. \n**Returns**\n\n- (String) --- the language code\n\n### #results\n\n def results() -\u003e Array\u003cDetection::Result\u003e\n\nThe list of detection results for the given text. The most likely language is listed first, and its\nattributes can be accessed through [#language](/ruby/docs/reference/google-cloud-translate-v2/latest/Google-Cloud-Translate-V2-Detection#Google__Cloud__Translate__V2__Detection_language_instance_ \"Google::Cloud::Translate::V2::Detection#language (method)\") and [#confidence](/ruby/docs/reference/google-cloud-translate-v2/latest/Google-Cloud-Translate-V2-Detection#Google__Cloud__Translate__V2__Detection_confidence_instance_ \"Google::Cloud::Translate::V2::Detection#confidence (method)\"). \n**Returns**\n\n- (Array\\\u003c[Detection::Result](./Google-Cloud-Translate-V2-Detection-Result)\\\u003e)\n\n### #text\n\n def text() -\u003e String\n\nThe text upon which the language detection was performed. \n**Returns**\n\n- (String)"]]