Wikisource:Google OCR

This tool has been superseded by the Wikimedia OCR feature, which is documented at mw:Help:Extension:Wikisource/Wikimedia OCR.
Category:Historical pages#Historical

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

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

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

To use Google OCR on any Wikisource, you should set it up as a Gadget (only interface administrators can do this).

  1. 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');
  2. Add the following to MediaWiki:Gadgets-definition:
    * GoogleOCR[ResourceLoader]|GoogleOCR.js
  3. 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 class prp-page-image; if it can't be found, this message is displayed in a bubble notification; e.g.: "No image found on this page"
  4. 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

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.

LanguageCodeLink
Multilingual WikisourceMediaWiki:GoogleOCR-local.js
Arabicarar:MediaWiki:Common.js ar:MediaWiki:Gadget-GoogleOCR.js
Assameseasas:MediaWiki:Common.js
Bulgarianbgbg:МедияУики:Gadget-GoogleOCR.js
Bengalibnbn:MediaWiki:Common.js
Englishenen:MediaWiki:Gadget-GoogleOCR.js
Spanisheses:MediaWiki:Gadget-GoogleOCR.js
Hindihihi:MediaWiki:Gadget-GoogleOCR.js
Kannadaknkn:MediaWiki:Gadget-GoogleOcr.js (not enabled)
Marathimrmr:MediaWiki:Common.js
Malayalammlml:MediaWiki:Gadget-GoogleOCR.js
Neapolitannapnap:MediaWiki:Gadget-GoogleOCR.js
Odiaoror:MediaWiki:Gadget-GoogleOCR.js
Russianruru:MediaWiki:Gadget-GoogleOCR.js
Sanskritsasa:MediaWiki:Common.js
Tamiltata:MediaWiki:Gadget-GoogleOCR.js
Telugutete:MediaWiki:Gadget-GoogleOCR.js
Ukrainianukuk:MediaWiki:Gadget-GoogleOCR.js
Gujaratigugu:MediaWiki:Gadget-GoogleOCR.js

Development

See also

Category:Wikisource tools
Category:Historical pages Category:Wikisource tools