Class: Google::Cloud::Vision::Annotation::Text::Page::Paragraph
- Inherits:
 - 
      Object
      
        
- Object
 - Google::Cloud::Vision::Annotation::Text::Page::Paragraph
 
 
- Defined in:
 - lib/google/cloud/vision/annotation/text.rb
 
Overview
Paragraph
Structural unit of text representing a number of words in certain order. See Block.
Instance Method Summary collapse
- 
  
    
      #bounds  ⇒ Array<Vertex> 
    
    
  
  
  
  
  
  
  
  
  
    
The bounding box for the paragraph.
 - 
  
    
      #break_type  ⇒ ::Symbol 
    
    
  
  
  
  
  
  
  
  
  
    
The type of a detected break at the start or end of the page.
 - 
  
    
      #languages  ⇒ Array<Language> 
    
    
  
  
  
  
  
  
  
  
  
    
A list of detected languages together with confidence.
 - 
  
    
      #prefix_break?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
True if a detected break prepends the page.
 - 
  
    
      #to_h  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    
Deeply converts object to a hash.
 - 
  
    
      #words  ⇒ Array<Word> 
    
    
  
  
  
  
  
  
  
  
  
    
List of words in this paragraph.
 
Instance Method Details
#bounds ⇒ Array<Vertex>
The bounding box for the paragraph. The vertices are in the order of top-left, top-right, bottom-right, bottom-left. When a rotation of the bounding box is detected the rotation is represented as around the top-left corner as defined when the text is read in the 'natural' orientation. For example:
- when the text is horizontal it might look like: 0----1 | | 3----2
 - when rotated 180 degrees around the top-left corner it becomes: 2----3 | | 1----0 and the vertice order will still be (0, 1, 2, 3).
 
      605 606 607 608 609 610  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 605 def bounds return [] unless @grpc.bounding_box @bounds ||= Array(@grpc.bounding_box.vertices).map do |v| Vertex.from_grpc v end end  | 
  
#break_type ⇒ ::Symbol
The type of a detected break at the start or end of the page.
      569 570 571 572  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 569 def break_type @grpc.property.detected_break && @grpc.property.detected_break.type.to_sym end  | 
  
#languages ⇒ Array<Language>
A list of detected languages together with confidence.
      557 558 559 560 561 562  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 557 def languages detected_languages = @grpc.property.detected_languages @languages ||= Array(detected_languages).map do |l| Language.from_grpc l end end  | 
  
#prefix_break? ⇒ Boolean
True if a detected break prepends the page.
      579 580 581 582  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 579 def prefix_break? @grpc.property.detected_break && @grpc.property.detected_break.is_prefix end  | 
  
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
      628 629 630 631 632  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 628 def to_h { languages: languages.map(&:to_h), break_type: break_type, prefix_break: prefix_break?, bounds: bounds.map(&:to_h), words: words.map(&:to_h) } end  |