diff --git a/README.md b/README.md index 918518c..64b0972 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ $file = $file_item->entity; $body = \Drupal::service('entity_to_text_tika.extractor.file_to_text')->fromFileToText($file, 'eng+fra'); ``` -or for an advanced usage avoiding multiple calls to Tika: +or for an advanced usage avoiding multiple calls to Tika by using cached ocr file: ```php // Anywhere at least once in the code (Eg. module.install) in order to prepare the storage. @@ -104,11 +104,13 @@ if (!$body) { ### Generate OCR via CLI -The module expose a Drush command to generate OCR for all Drupal files. +The module provides a Drush command for generating OCR (Optical Character Recognition) for all files within Drupal. +_It's important to note that this command should be used judiciously due to its potential resource intensity._ -This command is intended to be used sporadically, as it can be resource intensive. -The purpose is to generate OCR for all files that have not been OCR'ed yet. -This may be usefully after an initial install, a new OCR language has been added or right after files migration. +Its primary objective is to generate OCR for files that have not undergone OCR processing yet. +It's designed to work seamlessly with the Advanced feature set, leveraging cached OCR files efficiently. +This command proves especially useful after a fresh installation, the addition of a new OCR language, +or during file migrations. ```bash # Warmup all files that does not already have an associated .ocr file. diff --git a/modules/entity_to_text_tika/drush.services.yml b/modules/entity_to_text_tika/drush.services.yml index 53f4994..36f9499 100644 --- a/modules/entity_to_text_tika/drush.services.yml +++ b/modules/entity_to_text_tika/drush.services.yml @@ -1,6 +1,6 @@ services: - entity_to_text_tika.ocr_warmup_command: - class: \Drupal\entity_to_text_tika\Commands\OcrWarmupCommand + entity_to_text_tika.ocr_local_file_warmup_command: + class: \Drupal\entity_to_text_tika\Commands\OcrLocalFileCacheWarmup arguments: - '@database' - '@entity_type.manager' diff --git a/modules/entity_to_text_tika/src/Commands/OcrWarmupCommand.php b/modules/entity_to_text_tika/src/Commands/OcrLocalFileCacheWarmup.php similarity index 98% rename from modules/entity_to_text_tika/src/Commands/OcrWarmupCommand.php rename to modules/entity_to_text_tika/src/Commands/OcrLocalFileCacheWarmup.php index c2be24c..d1849cc 100644 --- a/modules/entity_to_text_tika/src/Commands/OcrWarmupCommand.php +++ b/modules/entity_to_text_tika/src/Commands/OcrLocalFileCacheWarmup.php @@ -11,9 +11,9 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * Drush Command to Warmup the Tika OCR Cache. + * Drush Command to Warmup the Tika OCR Local File Cache. */ -class OcrWarmupCommand extends DrushCommands { +class OcrLocalFileCacheWarmup extends DrushCommands { /** * The number of object processed by pages. diff --git a/modules/entity_to_text_tika/tests/src/Unit/OcrWarmupCommandTest.php b/modules/entity_to_text_tika/tests/src/Unit/OcrLocalFileCacheWarmupTest.php similarity index 97% rename from modules/entity_to_text_tika/tests/src/Unit/OcrWarmupCommandTest.php rename to modules/entity_to_text_tika/tests/src/Unit/OcrLocalFileCacheWarmupTest.php index 8772ecc..d967d7f 100644 --- a/modules/entity_to_text_tika/tests/src/Unit/OcrWarmupCommandTest.php +++ b/modules/entity_to_text_tika/tests/src/Unit/OcrLocalFileCacheWarmupTest.php @@ -6,7 +6,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Query\QueryInterface; -use Drupal\entity_to_text_tika\Commands\OcrWarmupCommand; +use Drupal\entity_to_text_tika\Commands\OcrLocalFileCacheWarmup; use Drupal\entity_to_text_tika\Extractor\FileToText; use Drupal\entity_to_text_tika\Storage\StorageInterface; use Drupal\file\Entity\File; @@ -16,14 +16,14 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * @coversDefaultClass \Drupal\entity_to_text_tika\Commands\OcrWarmupCommand + * @coversDefaultClass \Drupal\entity_to_text_tika\Commands\OcrLocalFileCacheWarmup * * @group entity_to_text * @group entity_to_text_tika * * @internal */ -final class OcrWarmupCommandTest extends UnitTestCase { +final class OcrLocalFileCacheWarmupTest extends UnitTestCase { /** * A mocked file storage service. @@ -49,7 +49,7 @@ final class OcrWarmupCommandTest extends UnitTestCase { /** * The command to test. * - * @var \Drupal\entity_to_text_tika\Commands\OcrWarmupCommand + * @var \Drupal\entity_to_text_tika\Commands\OcrLocalFileCacheWarmup */ protected $warmupCommand; @@ -74,7 +74,7 @@ protected function setUp(): void { $this->localFileStorage = $this->createMock(StorageInterface::class); $this->fileToText = $this->createMock(FileToText::class); - $this->warmupCommand = new OcrWarmupCommand( + $this->warmupCommand = new OcrLocalFileCacheWarmup( $database, $entity_type_manager, $this->fileToText,