Help: cannot OCR pdf file in Arabic

Hi to everybody
I am not new to Zotervo but very new to coding.
Yesterday I followed step by step the procedure to install the OCR plugin in Zotero. I have also followed the instruction of adding the various languages of my texts, one of which is Arabic. I re-run the script today (sudo port install tesseract-ara), to be sure to have done it correctly.

Even though I can run the script apparently correctly, the OCR in arabic does not work (thoug it works in English). When I copy the text in the pdf, I see while pasting that the computer has not detected that it is arabic, and I get a combination of characters such as : ey 2l ae ;-‘u_.-i':\} ‘L;JJ}L-H

Note that the OCRisation of texts in English worked from the start quite well (even though not as powerful as preview, especially if the characters are messy).
Thans for the help.
  • This is a question for the plugin dev. Have you changed the default language/script to use with Tesseract in the plugin settings?
  • If you haven't changed the language/script in the plugin settings yet, set the value to "ara" instead of "eng" for that PDF.
  • Hi, thank you for your quick answers.
    I have just found out how to do, but it does not seem to have any effect, I still see:
    ey 2l ae ;-‘u_.-i':\} ‘L;JJ}L-H
    Thanks for the ongoing help!
  • Just to give a screenshot, I could change the general setting, but when I go to plugin I do not have any language option
    https://s3.amazonaws.com/zotero.org/images/forums/u1908110/q72gbiq6oq038b0099ja.png

  • edited 19 days ago
    Oops, maybe I was unclear: the settings is where you set the language and script, and it stays that way until you change it again. There is no other language selection during the execution.
    Now since your settings look OK but this doesn't seem to work for you, can you share a link to the PDF, or perhaps just 2 pages? With that we can take a closer look.
  • Hello again, so if I change the language setting of all the Zotero software (which means my Zotero is all in Arabic), when I OCR-ize text they do come out in arabic; if I switch back to English, the texts in Arabic are not ocr-ized in Arabic.

    Although I like Arabic very much, I am more comfortable having my library in English. Does it mean that when I want to ocr-ize an Arabic text I have to switch to Zotero in Arabic all the time?

    The second issue, unrelated, is that the quality of the Ocr-ization is quite poor, even with texts in English.

    Thanks again
  • edited 19 days ago
    The language in the *Zotero OCR* plugin settings (which is what your screenshot is showing, 100% correctly) is strictly for OCR, there is no effect on Zotero itself, your library or anything else. And changing the Zotero language has no effect on the plugin.

    English OCR quality: I had not read that as an actual issue in your first post. But similarly, if you share the PDF we can take a look.
  • Hello again. Yes, it looks as if there is a general bug with Zotero.

    As mentioned, I switched the language to Arabic in the settings, but nothing changed. After some time, actually the day after, without me doing anything, the OCR has turned to Arabic, as you can see from the example here:
    دمحم دعسروتكدلاذاتسألاهبتكامنكل »موطرخلاةنيدم نع اوبتكنوريث
    However, what is incredible is that the OCR has nothing to do with the text underlined!!!

    https://s3.amazonaws.com/zotero.org/images/forums/u1908110/obbt4xju3gvpnevoic6s.png

    Moreover now, when I go back to an English text, and by doing so, I switch back to English in the Zotero settings, it is as if the machine was unable to see that I changed.
    So it gives me:
    ا م ي ه ! ب ل ا ا د 8 ع 5 ل م ع ن ل ط ع د م 1
    For the following text:
    https://s3.amazonaws.com/zotero.org/images/forums/u1908110/jfjchgza4ac4b8og6d2u.png

    And as you see, the setting are in English:
    https://s3.amazonaws.com/zotero.org/images/forums/u1908110/olmdjwtzlstc49xa2b1c.png

    Maybe I did something wrong with the scripts?

    Many thanks!
  • I don't see anything obviously wrong with what you did, so it could be a bug. But in order to say more, we really need you to provide a PDF.
  • I was about to do it, but it seems that I am so stupid not to see how I can upload a pdf here. When I try to do it, the pdf of my Finder window looks grey, as if I cannot do it. It seems it only accepts Jpeg....
  • Right, I forgot to mention that: you can upload the file to a file sharing platform such as https://file.kiwi and post the link here.
  • Here you go: https://file.kiwi/5f12ef6f#hAKozOog6GD3BC1yzTflpg

    I sent you both the normal pdf file and the one after OCR-ization.
    When I go on the ocr-ized version and I copy a line, again the arabic characters have nothing to do with the text.... Like all the times I have tried
    Thanks a lot!
  • Thank you very much! I'll take a look within the next few days.
    If you have a short English PDF that was poorly recognized, feel free to share it as well!
  • Thanks again for the PDFs!

    First of all, I must say that I do not read or speak Arabic, so I had to involve a few more tools in my analysis - I hope it will not make my explanations too hard to follow.

    Now we must distinguish at least 3 different levels of Arabic support:

    A. Storing Arabic characters
    B. Displaying Arabic characters
    C. Supporting Arabic text, with words and sentences compliant with the language rules

    -----

    As far as I can see, the Zotero OCR plugin has produced a PDF with Arabic characters in its text layer for you, as expected. This is determined by the "ara" settings when OCR is performed. Changing the interface language in Zotero in Settings/General section "Appearance and Language" (before or after the OCR) cannot affect that. Changing the plugin settings after the OCR will not change that either, unless you re-execute the OCR - and even if you do, the default behavior would be to produce a second OCRed PDF, not overwrite the 1st one. This is level A, it works normally on my laptop, and based on your files it has worked on your machine as well.

    -----

    There can be problems with level B, depending on how you are looking at the recognized text. I'm definitely seeing Arabic characters (sometimes a few Latin characters can appear where they should not, but mostly Arabic):
    - in the text file produced by the OCR in the same directory as the initial PDF (using a text editor that supports non-Latin scripts)
    - in the note attached to the Zotero item when I use the "Save output as a note" option
    - when I paste some copied text from the OCRed PDF into a word processor (LibreOffice Writer in my case)

    I suspect this is where you had some difficulties. If this is still happening, can you say exactly where you were observing non-Arabic text in the OCR (using what software, and ideally on which page of the provided PDF)?

    -----

    Finally, we have level C, which is the most difficult for me to evaluate.
    I have used Google Translate and my word processor to produce a short Arabic text, saved it to PDF, imported it into Zotero and OCRed it using the plugin. I translated the recognized text back into English using Google Translate, and most of it felt OK. The text selection was perhaps a bit tricky, and I think one short sentence at the beginning of my document was skipped. Certainly not perfect, but not catastrophic.

    In the PDF that you kindly provided and in my own, I think I can see some cases where the image and text layers of the output PDF are well aligned - it can be rather difficult to select a specific line. When the copied text does not match your selection, can you see the surprizing text somewhere else on the page? More generally, is it text that probably belongs in your PDF or does it feel completely random?

    This is what I have so far. I'd like to put level B out of the way before we delve deeper into level C.
Sign In or Register to comment.