{"word_count": 547, "character_count": 3618}
It is now very easy to read (automatically) some text that can be found in a pdf file. For instance, consider the program of the conference we had yesterday - and today - in Rennes&#62; library(pdftools)&#62; scan_pdf &#60;- pdf_text("http://crem.univ-rennes1.fr/Documents/Docs_sem_divers/2017_03_10-11_JJD/JDD_prog.pdf")&#62; cat(scan_pdf)Journées Jeunes DocteursProgramme du jeudi 9 mars 2017Faculty of Economics - Rennes - Amphi Henri Krier9h- 9h30 - Accueil9h30-10h15 :      Présentation du CREM, de la faculté et des activités de recherche liées du ou laboratoire10h15-10h50 :     Emmanuel LORENZON (Université de Bordeaux, GREThA)Collusion with a rent seeking agency in sponsored search auctions10h50-11h25 :     Julien BERTHOUMIEU (Université de Bordeaux, GREThA)The Impact of “At-the-Border” and “Behind-the-Border” Policies on Cost-Reducing Researchand DevelopmentCo-écrit avec Antoine Bouët(etc). As you can see, it is working well, even in French, where we have those weird letters (with accents). Here, it is working well because the pdf is vectorized, i.e. it was generated properly, by open office.But sometimes, we can have only a scanned version of a letteror just a picture with some typed text. I will not mention hand-writing because it is much more complex.The other day, my friend Fleur did show me a picture, and some very simple lines of code,&#62; library('tesseract')&#62; pic1="http://freakonometrics.hypotheses.org/files/2017/03/pic1.png"&#62; text_fr &#60;- ocr(pic1, engine = tesseract("fra"))&#62; cat(text_fr)Près de 14.400 décèsSi [épidémie de grippe est un phénomène récurrent. celle de2016—2017 présente plusieurs spéciﬁcités. outre sa virulence :une survenue plus précoce que d‘habitude. une activitémodérée en médecine ambulatoire. mais un impact fort enmilieu hospitalier.It looks like we've be able to extract typed text from a picture ! I want to check. I have to admit, first of all that installation on a linux machine is tricky: one has to install first leptonica, and then follow some guidelines to install tesseract (see also Artem's advices). It took me some time, but I've been able to install the package.The first important step, it to train the algorithm with some texts in French (because it is in French in my picture)&#62; library('tesseract')&#62; tesseract_download("fra")Then, I did try with the picture that Fleur did send me (the picture was inserted in the core of the message)&#62; pic2="http://freakonometrics.hypotheses.org/files/2017/03/pic2.png"&#62; text_fr &#60;- ocr(pic2, engine = tesseract("fra"))&#62; cat(text_fr)Près de 14400 decèss. mm….agw«… ………«…m ……a……u…u Dhs—ur; ;pmum…. ;: u……… W»: »… w…q…na… … ………… ………u…_ …… mm………… nwm/u… … mm…—mg…»— sa…… su a.…….…: :mmræwesdæ ; ; m…decnﬂwtülﬂws WWW…un»… M on m…… . … … .. m...… wma:.,… … V, …… … …;………yg…gn……… pe- le…samemeuuœwpwv m…mumClearly, something went wrong here. When I got that output, I thought that I did not train properly the function. But it was not the answer. As described in that post (in French) it is necessary to have a clean picture, to read it properlyAnd actually, if we zoom in our picture - the first one, used by Fleur, to show me that package - we havewhile for the second one - with a lower resolution - we haveIt is necessary to have a scan of a typed text with high resolution... And you have to admit that it is awesome....The good thing is that I have to work with a judge, in France, to assess quality of experts. And since most of the reports are typed, and then scanned, I am glad to have such a function. I just have to make sure that the resolution is high enough...