-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Register EventService class * Fire TextRecognizedEvent * Add TextRecognizedEvent class * Create sidecar and add recognized text to result * Added PdfOcrProcessor constructor argument * Added recognizedText variable to class * Added EventService * Refactored TextRecognizeEvent * Added EventService * Fixed tests * composer run cs:fix * Basic code cleanup Signed-off-by: Robin Windey <[email protected]> * Adjustments for #144 * Add additional tests * Refactor code to use more "high-level" SidecarFileAccessor Signed-off-by: Robin Windey <[email protected]> * Add docs for #144 * Add section for events to README.md * Remove TOC workflow Signed-off-by: Robin Windey <[email protected]> * Fix php7.4 syntax Signed-off-by: Robin Windey <[email protected]> * Add check if event is emitted Signed-off-by: Robin Windey <[email protected]> * Change TextRecognizedEvent interface to be more generic Linked to #144 * Adjust docs to match new interface Signed-off-by: Robin Windey <[email protected]> * Fix codecov Signed-off-by: Robin Windey <[email protected]> Signed-off-by: Robin Windey <[email protected]> Co-authored-by: Guido Schmitz <[email protected]> Co-authored-by: Robin Windey <[email protected]>
- Loading branch information
1 parent
d89d43a
commit 60a6ced
Showing
19 changed files
with
645 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2022 Robin Windey <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace OCA\WorkflowOcr\Events; | ||
|
||
use OCP\EventDispatcher\Event; | ||
use OCP\Files\File; | ||
|
||
/** | ||
* Class TextRecognizedEvent | ||
* | ||
* @package OCA\WorkflowOcr\Events | ||
*/ | ||
class TextRecognizedEvent extends Event { | ||
|
||
|
||
/** @var string */ | ||
private $recognizedText; | ||
|
||
/** @var File */ | ||
private $file; | ||
|
||
|
||
/** | ||
* TextRecognizedEvent constructor. | ||
*/ | ||
public function __construct(string $recognizedText, File $file) { | ||
parent::__construct(); | ||
|
||
$this->recognizedText = $recognizedText; | ||
$this->file = $file; | ||
} | ||
|
||
/** | ||
* @return string $recognizedText | ||
*/ | ||
public function getRecognizedText(): string { | ||
return $this->recognizedText; | ||
} | ||
|
||
/** | ||
* @return File $file | ||
*/ | ||
public function getFile(): File { | ||
return $this->file; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2022 Robin Windey <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace OCA\WorkflowOcr\Helper; | ||
|
||
interface ISidecarFileAccessor { | ||
/** | ||
* Creates a new temporary sidecar file for OCR text content. | ||
* If a file was already created, the path to the existing file is returned. | ||
* | ||
* @return string|bool Path to the sidecar file or false if the file could not be created | ||
*/ | ||
public function getOrCreateSidecarFile(); | ||
|
||
/** | ||
* Gets the content of the created sidecar file. File has to be created | ||
* before calling this method. | ||
*/ | ||
public function getSidecarFileContent(): string; | ||
} |
Oops, something went wrong.