Class: Mathpix::Result::Word

Inherits:
Object
  • Object
show all
Defined in:
lib/mathpix/result.rb

Overview

Word data structure for fine-grained bounding boxes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Word

Returns a new instance of Word.



254
255
256
# File 'lib/mathpix/result.rb', line 254

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



252
253
254
# File 'lib/mathpix/result.rb', line 252

def data
  @data
end

Instance Method Details

#bboxArray<Integer>?

Word bounding box

Returns:

  • (Array<Integer>, nil)


272
273
274
# File 'lib/mathpix/result.rb', line 272

def bbox
  data['bbox']
end

#confidenceFloat

Word confidence

Returns:

  • (Float)


266
267
268
# File 'lib/mathpix/result.rb', line 266

def confidence
  data['confidence'] || 0.0
end

#inspectString

Inspect

Returns:

  • (String)


284
285
286
# File 'lib/mathpix/result.rb', line 284

def inspect
  "#<Mathpix::Result::Word text=\"#{text}\" confidence=#{confidence}>"
end

#textString

Word text

Returns:

  • (String)


260
261
262
# File 'lib/mathpix/result.rb', line 260

def text
  data['text'] || ''
end

#to_hHash

Convert to hash

Returns:

  • (Hash)


278
279
280
# File 'lib/mathpix/result.rb', line 278

def to_h
  data
end