Wikisource:Google OCR
- This tool has been superseded by the Wikimedia OCR feature, which is documented at mw:Help:Extension:Wikisource/Wikimedia OCR.
This page is inactive and has been retained for historical interest. You can help by documenting its historical context and relevance. If you want to revive discussion regarding the subject, you are welcome to start a new discussion at the Scriptorium. |
The Google OCR tool adds a Page-namespace toolbar button that will derive text from the current page's image, via Google's Cloud Vision API OCR service.
It is used on Wikisources in languages with scripts that are not supported by the standard Tesseract OCR system. It should not be used where that system can be used instead, as there is a limit to the number of requests we can make against Google's services.
Any issues should be reported via Phabricator and tagged as Wikimedia OCR
. Report an issue now.
Note that only some languages are supported.
Direct usage
[edit]The tool can be used on its own to OCR any image that is hosted on Commons.
To do this, just go to the tool's web interface at https://ws-google-ocr.toolforge.org/ and paste in any image's full URL (i.e. after right clicking on an image and choosing 'copy image location'). This can be of use when processing images in the needing transcription category, for example.
Images with substantial amounts of text should be included in Wikisource instead, and proofread in the normal fashion.
Setting up as a user script or global script
[edit]Individual users can load Google OCR for themselves by adding the following to their common.js:
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:GoogleOCR.js&action=raw&ctype=text/javascript');
Wikis that want to make the OCR tool available by default for everyone can add the line above to their MediaWiki:Common.js.
You will also need to create the system messages mentioned below if they don't already exist on your wiki.
Setting up as a gadget
[edit]To use Google OCR on any Wikisource, you should set it up as a Gadget (only interface administrators can do this).
- Create
MediaWiki:Gadget-GoogleOCR.js
and add the following:mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:GoogleOCR.js&action=raw&ctype=text/javascript');
- Add the following to
MediaWiki:Gadgets-definition
:* GoogleOCR[ResourceLoader]|GoogleOCR.js
- Create the following system messages:
MediaWiki:google-ocr-button-label
— tooltip text for the buttons, e.g.: "Get text via Google OCR".MediaWiki:google-ocr-request-in-progress
— 'loading' text displayed while the OCR request is being carried out; e.g.: "Loading text from Google OCR".MediaWiki:google-ocr-no-text
— message displayed when the OCR tool didn't fail but also didn't return an error; e.g.: "No text retrieved from Google OCR"MediaWiki:google-ocr-image-not-found
— the image is expected to be in an element with classprp-page-image
; if it can't be found, this message is displayed in a bubble notification; e.g.: "No image found on this page"
- Enable the gadget for yourself, and test its operation. Bugs should be reported via Phabricator.
For more information about gadget configuration, see mw:Extension:Gadgets.
Sites using this
[edit]If your Wikisource is loading the Google OCR script as a gadget or a site script please list it here so we can keep you up to date with developments.
Development
[edit]- Project management: phabricator:tag/tool-wikisource-ocr
- The tool's web interface is fully translatable; see en.json for a current list of messages.
- Script: MediaWiki:GoogleOCR.js
- Tool source code: https://gerrit.wikimedia.org/r/admin/projects/labs/tools/wikisource-ocr
- Tool deployment: https://tools.wmflabs.org/ws-google-ocr/
- Cloud Vision API library: https://github.com/wikisource/google-cloud-vision-php/
- Toolbar icons: File:GoogleOcr WikiEditor button.png and File:GoogleOcr toolbar button.png