alexpgp: (Visa)
[personal profile] alexpgp
By the time I got to the labels in the translated documents, it was almost 4 pm. Editing the list of labels in the documents brought the overall number down to just 192.

Carefully crafting search-and-replace strings by hand in Word would've easily taken a minute per label, or a bit over three hours, with the risk that I would—somewhere in the middle of it all—gnaw off a leg and use it to bash my computers and monitors into just so much silicon refuse. Bad outcome.

So I went about automating the process, starting out by editing the org-mode table where I had collected all these labels into a text file where each line looked like:
<Russian label><TAB><English label translation>
I then created a keyboard macro to convert each line into:
strSoyuz(,) = "<Russian label>"
strSoyuz(,) = "<English label translation>"
I then dug into my rather dusty bag of tricks and created a Perl script that read all the lines in the saved file one by one, replaced the comma between the parentheses with a pair of numbers (representing the indices of a two-dimensional string array), and spit out a usable result.

The tricky part in the Perl script was to have the numbers increment in the following pattern:
(1,1), (1,2), (2,1), (2,2), (3,1), (3,2), ... (192,1), (192,2)
So that the file looked like:
strSoyuz(1,1) = <first Russian label>
strSoyuz(1,2) = <translation of first Russian label>
strSoyuz(2,1) = <second Russian label>
strSoyuz(2,2) = <translation of second Russian label>
...and so on
The last part of this marathon was actually pretty simple: write a Word VBA macro that declared a string array, initialized all 192 pairs, and then cycled through them all, replacing as it went.

I was actually a little surprised the macro worked right out of the chute, and the longest it took to run was about 20 seconds for a 30,000 word file that's chock full of such labels. A spot check shows no errors, but a more detailed assessment will have to wait until tomorrow.

The only thing left to do is address a bunch (and I mean a bunch) of figures in the files. Some of them actually have quite a bit of text in them, and I didn't taken them into account when planning this work. My bad. I must be slipping.

That said, this was a very challenging assignment. Tomorrow, I'm going to have to hit the ground running, from the work perspective, but I'm also going to have to spend what I fear will be long periods on the phone, speaking with insurance agents and doctors.

Never a dull moment around here, let me tell ya!

Cheers...

Profile

alexpgp: (Default)
alexpgp

January 2018

S M T W T F S
  1 2 3456
7 8910111213
14 15 16 17181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 2nd, 2025 05:48 pm
Powered by Dreamwidth Studios