Class: Mathpix::Result::Line
- Inherits:
-
Object
- Object
- Mathpix::Result::Line
- Defined in:
- lib/mathpix/result.rb
Overview
Line data structure for bounding boxes and confidence
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#bbox ⇒ Array<Integer>?
(also: #bounding_box)
Bounding box coordinates [x, y, width, height].
-
#confidence ⇒ Float
Line confidence.
-
#handwritten? ⇒ Boolean
Is this line handwritten?.
-
#initialize(data) ⇒ Line
constructor
A new instance of Line.
-
#inspect ⇒ String
Inspect.
-
#latex ⇒ String?
LaTeX for this line.
-
#mathml ⇒ String?
MathML for this line.
-
#printed? ⇒ Boolean
Is this line printed?.
-
#text ⇒ String
Line text content.
-
#to_h ⇒ Hash
Convert to hash.
-
#words ⇒ Array<Word>
Word-level data (if available).
Constructor Details
#initialize(data) ⇒ Line
Returns a new instance of Line.
181 182 183 |
# File 'lib/mathpix/result.rb', line 181 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
179 180 181 |
# File 'lib/mathpix/result.rb', line 179 def data @data end |
Instance Method Details
#bbox ⇒ Array<Integer>? Also known as: bounding_box
Bounding box coordinates [x, y, width, height]
199 200 201 |
# File 'lib/mathpix/result.rb', line 199 def bbox data['bbox'] end |
#confidence ⇒ Float
Line confidence
193 194 195 |
# File 'lib/mathpix/result.rb', line 193 def confidence data['confidence'] || 0.0 end |
#handwritten? ⇒ Boolean
Is this line handwritten?
207 208 209 |
# File 'lib/mathpix/result.rb', line 207 def handwritten? data['type'] == 'handwriting' end |
#inspect ⇒ String
Inspect
245 246 247 |
# File 'lib/mathpix/result.rb', line 245 def inspect "#<Mathpix::Result::Line text=\"#{text&.[](0..30)}\" confidence=#{confidence}>" end |
#latex ⇒ String?
LaTeX for this line
219 220 221 |
# File 'lib/mathpix/result.rb', line 219 def latex data['latex'] end |
#mathml ⇒ String?
MathML for this line
225 226 227 |
# File 'lib/mathpix/result.rb', line 225 def mathml data['mathml'] end |
#printed? ⇒ Boolean
Is this line printed?
213 214 215 |
# File 'lib/mathpix/result.rb', line 213 def printed? %w[printed print].include?(data['type']) end |
#text ⇒ String
Line text content
187 188 189 |
# File 'lib/mathpix/result.rb', line 187 def text data['text'] || '' end |
#to_h ⇒ Hash
Convert to hash
239 240 241 |
# File 'lib/mathpix/result.rb', line 239 def to_h data end |