Documentation

OcrPage
in package
implements Stringable

Ocr extraction for a single page.

Table of Contents

Interfaces

Stringable

Properties

$allWords  : array<string|int, OcrWord>
$lines  : array<string|int, OcrLine>

Methods

__construct()  : mixed
__toString()  : string
getAllLines()  : array<string|int, OcrLine>
Retrieves all lines on the page.
getAllWords()  : array<string|int, OcrWord>
Retrieves all words on the page.
getMinMaxX()  : int
Compares word positions on the X axis. Returns a sort-compliant result (0;-1;1).
getMinMaxY()  : int
Compares word positions on the Y axis. Returns a sort-compliant result (0;-1;1).
areWordsOnSameLine()  : bool
Checks whether the words are on the same line.
toLines()  : array<string|int, OcrLine>
Puts all words on the page into an array of lines.

Properties

$allWords

private array<string|int, OcrWord> $allWords

List of all words.

Methods

__construct()

public __construct(array<string, int|float|string|bool|null|array<string|int, mixed>> $rawPrediction) : mixed
Parameters
$rawPrediction : array<string, int|float|string|bool|null|array<string|int, mixed>>

Raw prediction array.

__toString()

public __toString() : string
Return values
string

String representation.

getAllLines()

Retrieves all lines on the page.

public getAllLines() : array<string|int, OcrLine>
Return values
array<string|int, OcrLine>

getAllWords()

Retrieves all words on the page.

public getAllWords() : array<string|int, OcrWord>
Return values
array<string|int, OcrWord>

getMinMaxX()

Compares word positions on the X axis. Returns a sort-compliant result (0;-1;1).

public static getMinMaxX(OcrWord $word1, OcrWord $word2) : int
Parameters
$word1 : OcrWord

First word.

$word2 : OcrWord

Second word.

Return values
int

getMinMaxY()

Compares word positions on the Y axis. Returns a sort-compliant result (0;-1;1).

public static getMinMaxY(OcrWord $word1, OcrWord $word2) : int
Parameters
$word1 : OcrWord

First word.

$word2 : OcrWord

Second word.

Return values
int

areWordsOnSameLine()

Checks whether the words are on the same line.

private static areWordsOnSameLine(OcrWord $currentWord, OcrWord $nextWord) : bool
Parameters
$currentWord : OcrWord

Reference word to compare.

$nextWord : OcrWord

Next word to compare.

Return values
bool

toLines()

Puts all words on the page into an array of lines.

private toLines() : array<string|int, OcrLine>
Return values
array<string|int, OcrLine>
On this page

Search results