22
33namespace Mindee \Parsing \Common \Ocr ;
44
5- use Mindee \Geometry \MinMaxUtils ;
6- use Mindee \Geometry \PolygonUtils ;
7-
85/**
96 * OCR extraction for a single page.
107 */
@@ -22,28 +19,28 @@ class OcrPage
2219 /**
2320 * Checks whether the words are on the same line.
2421 *
25- * @param \Mindee\Parsing\Common\Ocr\ OcrWord $currentWord Reference word to compare.
26- * @param \Mindee\Parsing\Common\Ocr\ OcrWord $nextWord Next word to compare.
22+ * @param OcrWord $currentWord Reference word to compare.
23+ * @param OcrWord $nextWord Next word to compare.
2724 * @return boolean
2825 */
2926 private static function areWordsOnSameLine (OcrWord $ currentWord , OcrWord $ nextWord ): bool
3027 {
31- $ currentInNext = PolygonUtils:: isPointInPolygonY ( $ currentWord ->polygon ->getCentroid (), $ nextWord ->polygon );
32- $ nextInCurrent = PolygonUtils:: isPointInPolygonY ( $ nextWord ->polygon ->getCentroid (), $ currentWord ->polygon );
28+ $ currentInNext = $ nextWord ->polygon ->isPointInY ( $ currentWord ->polygon -> getCentroid () );
29+ $ nextInCurrent = $ currentWord ->polygon ->isPointInY ( $ nextWord ->polygon -> getCentroid () );
3330 return $ currentInNext || $ nextInCurrent ;
3431 }
3532
3633 /**
3734 * Compares word positions on the X axis. Returns a sort-compliant result (0;-1;1).
3835 *
39- * @param \Mindee\Parsing\Common\Ocr\ OcrWord $word1 First word.
40- * @param \Mindee\Parsing\Common\Ocr\ OcrWord $word2 Second word.
36+ * @param OcrWord $word1 First word.
37+ * @param OcrWord $word2 Second word.
4138 * @return integer
4239 */
4340 public static function getMinMaxX (OcrWord $ word1 , OcrWord $ word2 ): int
4441 {
45- $ word1X = MinMaxUtils:: getMinMaxX ( $ word1 ->polygon ->getCoordinates () )->getMin ();
46- $ word2X = MinMaxUtils:: getMinMaxX ( $ word2 ->polygon ->getCoordinates () )->getMin ();
42+ $ word1X = $ word1 ->polygon ->getMinMaxX ( )->getMin ();
43+ $ word2X = $ word2 ->polygon ->getMinMaxX ( )->getMin ();
4744 if ($ word1X == $ word2X ) {
4845 return 0 ;
4946 }
@@ -53,14 +50,14 @@ public static function getMinMaxX(OcrWord $word1, OcrWord $word2): int
5350 /**
5451 * Compares word positions on the Y axis. Returns a sort-compliant result (0;-1;1).
5552 *
56- * @param \Mindee\Parsing\Common\Ocr\ OcrWord $word1 First word.
57- * @param \Mindee\Parsing\Common\Ocr\ OcrWord $word2 Second word.
53+ * @param OcrWord $word1 First word.
54+ * @param OcrWord $word2 Second word.
5855 * @return integer
5956 */
6057 public static function getMinMaxY (OcrWord $ word1 , OcrWord $ word2 ): int
6158 {
62- $ word1Y = MinMaxUtils:: getMinMaxY ( $ word1 ->polygon ->getCoordinates () )->getMin ();
63- $ word2Y = MinMaxUtils:: getMinMaxY ( $ word2 ->polygon ->getCoordinates () )->getMin ();
59+ $ word1Y = $ word1 ->polygon ->getMinMaxY ( )->getMin ();
60+ $ word2Y = $ word2 ->polygon ->getMinMaxY ( )->getMin ();
6461 if ($ word1Y == $ word2Y ) {
6562 return 0 ;
6663 }
0 commit comments