Skip to content

Corrections diverses. - #11

Open
Daniel-KM wants to merge 36 commits into
smachefert:masterfrom
Daniel-KM:master
Open

Corrections diverses.#11
Daniel-KM wants to merge 36 commits into
smachefert:masterfrom
Daniel-KM:master

Conversation

@Daniel-KM

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings April 21, 2026 09:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the ExtractOcr Omeka S module with multiple extraction/packaging improvements, including new TSV output variants, better job behavior, and an upgrade path for existing installs.

Changes:

  • Add a second TSV export mode (full TSV vs grouped-by-word) and update extraction/storage logic accordingly.
  • Introduce an upgrade script to migrate filenames/settings and bump module metadata (version + constraints).
  • Add composer metadata, update translations/docs, and improve operational characteristics (memory clearing, CLI tool checks).

Reviewed changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/Job/ExtractOcr.php Adds new TSV format handling, content-only mode, CLI checks, and memory management improvements.
src/Form/ConfigForm.php Updates admin config options to expose the new TSV formats and documentation link.
Module.php Updates install checks/messages, adds deferred job dispatch and EasyAdmin integration, extends format handling.
data/scripts/upgrade.php New upgrade script to migrate settings and rename derivative files/DB sources.
config/module.ini Bumps module version and updates Omeka version constraint.
config/module.config.php Adjusts translator loader config and defaults (notably content property default).
README.md Expands documentation to explain formats and recommended usage.
language/template.pot Regenerates POT with new/updated strings.
language/fr.po Updates French translations for new/changed strings.
language/fr.mo Adds compiled French translation binary.
composer.json / composer.lock Adds Composer package metadata for the module.
.gitignore Expands ignored paths (vendor/node/phpunit/etc.).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Module.php
Comment on lines 284 to 299
$extensions = [
\ExtractOcr\Job\ExtractOcr::FORMAT_ALTO => 'alto.xml',
\ExtractOcr\Job\ExtractOcr::FORMAT_PDF2XML => 'xml',
\ExtractOcr\Job\ExtractOcr::FORMAT_TSV => 'tsv',
\ExtractOcr\Job\ExtractOcr::FORMAT_TSV_BY_WORD => 'tsv',
];
$settings = $services->get('Omeka\Settings');
$targetTypesFiles = $settings->get('extractocr_types_files') ?: [];
$targetTypesFiles = array_intersect($targetTypesFiles, array_flip($extensions));
$targetTypesMedia = $settings->get('extractocr_types_media') ?: [];
$targetTypesMedia = array_intersect($targetTypesMedia, array_flip($extensions));
if (!$targetTypesFiles && !$targetTypesMedia ) {
$targetContentStore = $settings->get('extractocr_content_store') ?: [];
$targetContentStore = array_intersect($targetContentStore, ['item', 'media_pdf', 'media_extracted']);
if (!$targetTypesFiles && !$targetTypesMedia && !$targetContentStore) {
return;
}

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In extractOcr(), the filtering of configured formats is broken: array_intersect($targetTypesFiles, array_flip($extensions)) compares selected mime types against extension strings, so $targetTypesFiles/$targetTypesMedia will always end up empty and automatic extraction on item update won’t run as expected. This method also still uses legacy extension/filename conventions (xml, tsv) and uses the selected format string as mediaType when checking existing OCR media; that won’t match the actual media types produced by the job (e.g. the new TSV-by-word format maps to text/tab-separated-values and file extensions like by-word.tsv, full.tsv, pdf2xml.xml). Align the format filtering + extension/mediaType mapping here with src/Job/ExtractOcr::perform() so existing files/medias are detected correctly and jobs aren’t skipped or re-dispatched unnecessarily.

Copilot uses AI. Check for mistakes.
Comment thread Module.php
],
'attributes' => [
'id' => 'item_ids',
'placeholder' => '2-6 8 38-52 80-', // @ translate

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The translator extraction marker is written as // @ translate (with a space). If your translation tooling relies on the exact @translate token, this placeholder string may be missed during POT generation; change it to // @translate for consistency with the rest of the module.

Suggested change
'placeholder' => '2-6 8 38-52 80-', // @ translate
'placeholder' => '2-6 8 38-52 80-', // @translate

Copilot uses AI. Check for mistakes.
Comment thread language/fr.po
#: src/Job/ExtractOcr.php:130
#: Module.php:487
msgid "Extract OCR: Extract ocr from files"
msgstr "Extract OCR : extraire l’ocr des fichierse"

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s a typo in the French translation: “fichierse” should be “fichiers”.

Suggested change
msgstr "Extract OCR : extraire l’ocr des fichierse"
msgstr "Extract OCR : extraire l’ocr des fichiers"

Copilot uses AI. Check for mistakes.
Comment thread data/scripts/upgrade.php
Comment on lines +148 to +156
$newFilepath = substr_replace($filepath, '.by-word.tsv', -4);
$result = @rename($filepath, $newFilepath);
if (!$result) {
$message = new Message(
$translator->translate('The file "%s" cannot be renamed.'), // @translate
$filename
);
}
}

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On rename failure, a Message is created but never logged, shown to the user, or used to fail the upgrade. As a result, file renames can silently fail and leave the installation in a partially-upgraded state. Consider reporting these failures via $messenger->addError() / $logger->err() and/or throwing ModuleCannotInstallException when renames are required for correctness.

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment on lines +18 to +25
allows smaller files and a slightly faster search, but a slighly less accurate
display. For alto, it is a valid but basic alto that does not contains metadata
about fonts or structure.

There are two tsv formats: the words can be stored globally, so the index is
smaller and the search is quicker, or one by one, so an exact search can be done
when there are multiple words and the search wrapped with `"`. The tsv format
does not allows to display the transcription in IIIF viewers, but it allows to

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor wording/spelling issues in this updated documentation section make it harder to read: e.g. “slighly” → “slightly”, “does not contains” → “does not contain”, and “does not allows” → “does not allow”. Consider proofreading these lines.

Suggested change
allows smaller files and a slightly faster search, but a slighly less accurate
display. For alto, it is a valid but basic alto that does not contains metadata
about fonts or structure.
There are two tsv formats: the words can be stored globally, so the index is
smaller and the search is quicker, or one by one, so an exact search can be done
when there are multiple words and the search wrapped with `"`. The tsv format
does not allows to display the transcription in IIIF viewers, but it allows to
allows smaller files and a slightly faster search, but a slightly less accurate
display. For alto, it is a valid but basic alto that does not contain metadata
about fonts or structure.
There are two tsv formats: the words can be stored globally, so the index is
smaller and the search is quicker, or one by one, so an exact search can be done
when there are multiple words and the search wrapped with `"`. The tsv format
does not allow to display the transcription in IIIF viewers, but it allows to

Copilot uses AI. Check for mistakes.
Comment thread Module.php
Comment on lines +32 to +38
'The command-line utility pdftotext is not available. Install the package poppler-utils.' //@translate
);
}

if ((int) shell_exec('hash pdftohtml 2>&- || echo 1')) {
throw new ModuleCannotInstallException(
'The command-line utility pdftohtml is not available. Install the package poppler-utils.' //@translate

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These install-time exception messages are now hardcoded strings (not passed through $t->translate()), so they won’t be localized even though they’re marked //@translate and appear in the POT. Consider translating them before throwing ModuleCannotInstallException (consistent with the other install checks below).

Suggested change
'The command-line utility pdftotext is not available. Install the package poppler-utils.' //@translate
);
}
if ((int) shell_exec('hash pdftohtml 2>&- || echo 1')) {
throw new ModuleCannotInstallException(
'The command-line utility pdftohtml is not available. Install the package poppler-utils.' //@translate
$t->translate('The command-line utility pdftotext is not available. Install the package poppler-utils.') // @translate
);
}
if ((int) shell_exec('hash pdftohtml 2>&- || echo 1')) {
throw new ModuleCannotInstallException(
$t->translate('The command-line utility pdftohtml is not available. Install the package poppler-utils.') // @translate

Copilot uses AI. Check for mistakes.
Comment thread src/Form/ConfigForm.php
'options' => [
'label' => 'Create file for formats', // @translate
'info' => 'For more info on formats, see readme.', // @translate
'documentation' => 'https://gitlab.com/Daniel-KM/Omeka-S-module-ExtractOcr#extract-ocr-modue-for-omeka-s',

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation URL has a typo (extract-ocr-modue-for-omeka-s), which makes the help link in the admin config form incorrect. Update it to the correct anchor in the README so admins can reach the referenced documentation.

Suggested change
'documentation' => 'https://gitlab.com/Daniel-KM/Omeka-S-module-ExtractOcr#extract-ocr-modue-for-omeka-s',
'documentation' => 'https://gitlab.com/Daniel-KM/Omeka-S-module-ExtractOcr#extract-ocr-module-for-omeka-s',

Copilot uses AI. Check for mistakes.
Comment thread language/fr.po
#: data/scripts/upgrade.php:152 data/scripts/upgrade.php:184
#, php-format
msgid "The file \"%s\" cannot be renamed."
msgstr "Le dossier « %s » ne peut pas être renommé."

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The French translation for “The file "%s" cannot be renamed.” currently says “Le dossier …” (folder) instead of “Le fichier …” (file), which changes the meaning and is confusing in upgrade error reporting. Update the msgstr accordingly.

Suggested change
msgstr "Le dossier « %s » ne peut pas être renommé."
msgstr "Le fichier « %s » ne peut pas être renommé."

Copilot uses AI. Check for mistakes.
Comment thread data/scripts/upgrade.php
Comment on lines +184 to +186
$translator->translate('The file "%s" cannot be renamed.'), // @translate
$filename
);

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On rename failure in the /pdf2xml loop, a Message is created but never emitted. This can silently leave old filenames on disk while the DB/settings are updated, leading to mismatches. Report/handle the failure (messenger/logger and/or abort the upgrade) so admins know remediation is needed.

Suggested change
$translator->translate('The file "%s" cannot be renamed.'), // @translate
$filename
);
$translator->translate('The file "%1$s" cannot be renamed to "%2$s".'), // @translate
$filepath,
$newFilepath
);
$logger->err((string) $message);
throw new ModuleCannotInstallException((string) $message);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants