Skip to content
This repository was archived by the owner on May 28, 2026. It is now read-only.

Commit 105fce5

Browse files
authored
Add Northern Min (mnp), and switch the Google API method
* Add Northern Min (mnp) language to Google Cloud Vision engine. * Use documentTextDetection instead of textDetection for better recognition of complex diacritic characters used in mnp. * Fix phpcs line length warnings in GoogleCloudVisionEngine Bug: T383002
1 parent 70ea70a commit 105fce5

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

public/models.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,10 @@
548548
"languages": ["mn"],
549549
"title": "Монгол / Mongolian / Cyrl / Supports handwriting"
550550
},
551+
"mnp": {
552+
"languages": ["mnp"],
553+
"title": "Mìng-dĕ̤ng-ngỳ̄ / Northern Min / Latn / Supports handwriting"
554+
},
551555
"moh": {
552556
"languages": ["moh"],
553557
"title": "Kanienʼkéha / Mohawk / Latn / Mapped / Supports handwriting"

src/Engine/GoogleCloudVisionEngine.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare( strict_types = 1 );
2+
declare( strict_types=1 );
33

44
namespace App\Engine;
55

@@ -68,17 +68,24 @@ public function getResult(
6868

6969
$image = $this->getImage( $imageUrl, $crop );
7070
$imageUrlOrData = $image->hasData() ? $image->getData() : $image->getUrl();
71-
$response = $this->imageAnnotator->textDetection( $imageUrlOrData, [ 'imageContext' => $imageContext ] );
71+
$response = $this->imageAnnotator->documentTextDetection(
72+
$imageUrlOrData,
73+
[ 'imageContext' => $imageContext ]
74+
);
7275

7376
// Re-try with direct upload if the error returned is something similar to
7477
// "The URL does not appear to be accessible by us. Please double check or download the content and pass it in."
7578
// There doesn't seem to be a specific error code for this (it is usually 3, but that's also used for other
7679
// things), so it seems like we have to check the actual message string.
77-
if ( $response->getError()
80+
if (
81+
$response->getError()
7882
&& stripos( $response->getError()->getMessage(), 'download the content and pass it in' ) !== false
7983
) {
8084
$image = $this->getImage( $imageUrl, $crop, self::DO_DOWNLOAD_IMAGE );
81-
$response = $this->imageAnnotator->textDetection( $image->getData(), [ 'imageContext' => $imageContext ] );
85+
$response = $this->imageAnnotator->documentTextDetection(
86+
$image->getData(),
87+
[ 'imageContext' => $imageContext ]
88+
);
8289
}
8390

8491
// Other errors, report to the user.

0 commit comments

Comments
 (0)