Class: Google::Cloud::Vision::Annotation::Text::Page::Language

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/vision/annotation/text.rb

Overview

Language

A language within a detected text (OCR). See Google::Cloud::Vision::Annotation::Text#pages.

Examples:

require "google/cloud/vision"

vision = Google::Cloud::Vision.new

image = vision.image "path/to/text.png"
text = image.text
page = text.pages.first

language = page.languages.first
language.code #=> "en"

Instance Method Summary collapse

Instance Method Details

#codeString

The language code detected for a structural component.

Returns:



971
972
973
# File 'lib/google/cloud/vision/annotation/text.rb', line 971

def code
  @grpc.language_code
end

#confidenceFloat

Confidence of detected language.

Returns:

  • (Float)

    A value in the range [0,1].



980
981
982
# File 'lib/google/cloud/vision/annotation/text.rb', line 980

def confidence
  @grpc.confidence
end

#to_hHash

Deeply converts object to a hash. All keys will be symbolized.

Returns:

  • (Hash)


989
990
991
# File 'lib/google/cloud/vision/annotation/text.rb', line 989

def to_h
  { code: code, confidence: confidence }
end