Frederick the Great discussion post 9
Jan. 13th, 2020 09:09 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
...I leave you guys alone for one weekend and it's time for a new Fritz post, lol!
I'm gonna reply to the previous post comments but I guess new letter-reading, etc. should go in this one :)
Frederick the Great links
I'm gonna reply to the previous post comments but I guess new letter-reading, etc. should go in this one :)
Frederick the Great links
Re: Fritzian library
Date: 2020-01-17 05:04 pm (UTC)But if anyone wants to bribe me, the next item on my wishlist is a 200-page, 20-euro monograph called "Des Königs Knabe: Friedrich der Große und Antinous." If anyone wanted the remaining Heinrich letters, someone could promise to Venmo me the money after I deliver the letters and someone else could read and summarize the volume. (An obvious division of labor suggests itself here. ;) Especially since someone has already expressed willingness to commission the Wilhelmine letters, and ended up getting those and many others for free.)
Re: Fritzian library
Date: 2020-01-17 05:43 pm (UTC)Re: Fritzian library
Date: 2020-01-17 05:47 pm (UTC)Re: Fritzian library
Date: 2020-01-18 11:24 pm (UTC)So last night I needed a break from assembling material for Rheinsberg posts, and since I was very tired, I thought some mindless OCR cleanup would do the trick.
Being me, I almost immediately decided to start seeing if I could solve the biggest problem in an automated way. And the biggest problem was that moving around of lines that I'd talked about. For instance, the following four lines:
souciant pas de sa perte et relevant toujours les assaillants de nouvelles
troupes, la garnison avait été forcée. Voilà cependant des circon-
stances que je ne saurais vous garantir, n'ayant pas de nouvelles sûres
sur cela.
were rendered by the Google API as:
souciant pas de sa perte et relevant toujours les assaillants de nouvelles
troupes, la garnison avait été forcée.
stances que je ne saurais vous garantir, n'ayant pas de nouvelles sûres
sur cela.
Voilà cependant des circon-
Which has all the right words, but half of line 2 is suddenly a new line 5. And that just seemed weird.
Well, from my reverse-engineering, it looks like Google is doing OCR as a two-step process:
1) Detecting the location of each individual word on the page.
2) Assembling the words together in text form and give them to the user.
Well, because Google is nice like that (thank you, Google!), the API actually gives you the results of both steps. In other words, I was getting, not only the garbled text printout above, but also each individual word with x and y coordinates. For example:
{ "description": "avait", "boundingPoly": { "vertices": [ { "x": 323, "y": 874 }, { "x": 368, "y": 873 }, { "x": 368, "y": 888 }, { "x": 323, "y": 889 } ] } },
{ "description": "été", "boundingPoly": { "vertices": [ { "x": 386, "y": 875 }, { "x": 412, "y": 875 }, { "x": 412, "y": 889 }, { "x": 386, "y": 889 } ] } },
{ "description": "forcée.", "boundingPoly": { "vertices": [ { "x": 429, "y": 874 }, { "x": 487, "y": 873 }, { "x": 487, "y": 889 }, { "x": 429, "y": 890 } ] } },
{ "description": "stances", "boundingPoly": { "vertices": [ { "x": 95, "y": 903 }, { "x": 160, "y": 903 }, { "x": 160, "y": 916 }, { "x": 95, "y": 916 } ] } }
And by closely inspecting the x and y coordinates of individual words that were getting returned out of order, I realized that the coordinates were correct. It was step 2, assembly of individual words, that the Google API was getting wrong.
Well, step 1 requires a team of Google-level engineers and I would never try it, but step 2 is pretty easy. You just have to sort a bunch of numbers in order to get the correct order, and then print out the words in the correct order, sans coordinates.
I did it! I now have a script that bypasses the printout from Google and constructs its own printout based on the raw coordinates.
Why is this important? Well, the detection of individual words looks good enough to me that as long as the words are in the correct order, I think I can get away with not comparing the OCR to the original text.
I still need to do manual cleanup of all 1500 or so letters, because automatically detecting things like footnotes, ends of letters, paragraph breaks , etc. is hard, and I'm going to have to go through and make judgments as to which text I'm interested in passing to the translate API and which text I want to discard.
But the key point here is that I can put all this in one file and eyeball it, and I do not have to open 1500 image files and compare them side-by-side to make sure the text is in the right place. If the first 5 or so letters I've tried this on are indicative, that is a solved problem.
Being able to scan through one long file and reformat things using macros is going to be a million times faster than opening 1500 images and moving my eyeballs back and forth as I try to make sure the OCR text matches the scanned text.
It's still going to be a little while before I can deliver (especially because of my backlog of
Um, if all this goes well and I'm able to deliver these OCRed-plus-translated letters, I'm still going to request the Antinous book. :P I think I'll have earned it.
Re: Fritzian library
Date: 2020-01-19 11:54 am (UTC)Re: Fritzian library
Date: 2020-01-22 09:56 pm (UTC)*weep*
Why I wasn't backing up the file every HOUR or at least every day, I do not know. But I definitely meant to back it up as soon as I was done with the three days of cleanup.
It will hopefully take a little less time to redo than it did in the first place, since I did make improvements to the process as I went along, to speed things up, but depending on my mood, I may continue to be behind on comments for a bit, while I beat this thing into submission.
I was SO! CLOSE!
Re: Fritzian library
Date: 2020-01-23 02:31 am (UTC)Re: Fritzian library
Date: 2020-01-23 03:17 am (UTC)If only I had a monkey I could blame.
Crackfic where Mimi was framed.Have made good progress on recouping our losses; have backed up; will continue tomorrow.
Re: Fritzian library
Date: 2020-01-26 04:17 am (UTC)More or less caught up on post 9 comments, so tomorrow after finishing Heinrich, the plan is to catch up on post 10, selenak's no doubt awesome fic, Rheinsberg posts, and any new comments that come in while I'm asleep! This order of events subject to being interrupted by any incoming comments with the word "Katte" in the subject. :P