Skip to content

Commit

Permalink
rename command warmup to reflect local-file warmup
Browse files Browse the repository at this point in the history
  • Loading branch information
WengerK committed Apr 28, 2024
1 parent ff3ef11 commit acffe4c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions modules/entity_to_text_tika/drush.services.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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;

Expand All @@ -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,
Expand Down

0 comments on commit acffe4c

Please sign in to comment.