Wikisource:Google OCR

From Wikisource
Jump to navigation Jump to search
This tool has been superseded by the Wikimedia OCR feature, which is documented at mw:Help:Extension:Wikisource/Wikimedia OCR.

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).

  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[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.

Language Code Link
Multilingual Wikisource MediaWiki:GoogleOCR-local.js
Arabic ar ar:MediaWiki:Common.js ar:MediaWiki:Gadget-GoogleOCR.js
Assamese as as:MediaWiki:Common.js
Bulgarian bg bg:МедияУики:Gadget-GoogleOCR.js
Bengali bn bn:MediaWiki:Common.js
English en en:MediaWiki:Gadget-GoogleOCR.js
Spanish es es:MediaWiki:Gadget-GoogleOCR.js
Hindi hi hi:MediaWiki:Gadget-GoogleOCR.js
Kannada kn kn:MediaWiki:Gadget-GoogleOcr.js (not enabled)
Marathi mr mr:MediaWiki:Common.js
Malayalam ml ml:MediaWiki:Gadget-GoogleOCR.js
Neapolitan nap nap:MediaWiki:Gadget-GoogleOCR.js
Odia or or:MediaWiki:Gadget-GoogleOCR.js
Russian ru ru:MediaWiki:Gadget-GoogleOCR.js
Sanskrit sa sa:MediaWiki:Common.js
Tamil ta ta:MediaWiki:Gadget-GoogleOCR.js
Telugu te te:MediaWiki:Gadget-GoogleOCR.js
Ukrainian uk uk:MediaWiki:Gadget-GoogleOCR.js
Gujarati gu gu:MediaWiki:Gadget-GoogleOCR.js

Development[edit]

See also[edit]