Showing posts with label Google Translate. Show all posts
Showing posts with label Google Translate. Show all posts

Thursday, November 7, 2013

Лучше Девушка - My Russian Picture Book


Introduction

It’s probably about time for a Russian-themed blog post, since (according to Pageview stats) 11% of my albertnet audience is Ukrainian and another 4% is Russian.

This post is about a children’s picture book that I wrote in Russian for a high school class.  The book itself is presented here, with my shockingly bad illustrations, along with a handy English translation that gave me some trouble (more on this later).

Beyond the story itself, I describe here how my brother wrote computer software to enable me to actually type out the story in Russian.  (This was a pretty big deal back in 1986.)  Meanwhile, the simple tale is greatly enriched by the story of my civil-war-torn Russian class, so I’ll give some background on that, with further observations sprinkled among the storybook pages.


The translation

It’s been a very long time since I studied Russian, and in the interim I’ve stuffed my head with French and Latin and also killed off a tremendous number of brain cells riding my bike too hard.  Thus, when my mom—having decided I can finally be trusted with a precious family heirloom—returned to me the picture book (which she had been archiving), I was unable to read it.  I had written the book using the simplest prose imaginable, but now I found myself stymied.

I made a little stab at translation using Google Translate, but gave up quickly.  For one thing, you have to enter each word using the Cyrillic alphabet of Russian, and the mouse-based methodology for this is clunky:


Second, when writing this book my spelling was less than perfect, and it’s difficult to Google-translate misspelled words.  Consider сотворил above:  in my book I’d spelled it сотровил.  And then there’s the grammar to consider.

And so, oddly enough, I had to find somebody to translate my own book into my native tongue.  I wasn’t about to post a craigslist ad, because a) how could I validate the ability of some random would-be translator? and b) my budget for this project is based on my income from this blog—that is, it’s nonexistent.  Fortunately, my daughter has made a new friend in school who is fluent in Russian (she speaks it at home).  This friend not only translated my book, but read it aloud to us in Russian, which was a pleasure to hear.

The font and typesetting

The teacher, when assigning us the children’s book, said we had to bind all the pages up nicely, with a cover and everything, and I refused.  “This isn’t an arts and crafts class,” I said snottily.  (Like so many teens, I was a jerk.)  “But I will type it,” I declared.  I didn’t know exactly how I’d do this, and of course the teacher assumed I was just BS-ing her.

I asked my brother Bryan if he could create a Russian character set for me on the computer, and software that could typeset my story.  He didn’t ask, “What’s in it for me?!” but immediately accepted the challenge just because it sounded cool.  He didn’t have his own computer—not so many people did back then—but we had access to our dad’s Hewlett Packard 85 computer (described here).  The only problem was, its built-in thermal printer used a spool of paper that was only about four inches wide.  So Bryan borrowed his friend Thaine’s HP-86, and wrote a program on it using the HP version of the BASIC programming language. 


The program drew the characters using the graphics capability of the computer.  Bryan had me design the characters myself on 8½-by-11 graph paper.  They were huge—one graph-paper box per pixel—and he shrunk them down with the software (this was long before scanners and I have no recollection of how he got from paper-based drawings to computer pixels).  His program gave me rudimentary word processing capabilities and mapped the Cyrillic characters to their nearest QWERTY keyboard equivalent.  The font was lovely; in fact, his characters were far prettier than those of the existing English-language font sets available for a dot-matrix printer.  Compare:

When I’d written the story, typed it, printed it, and added my pictures, it did seem like a shame to just staple it.  Before I even had time to think about how I might bind it, Thaine’s girlfriend Erika offered to make a cover for me.  She used black silk for the back cover, and a brilliant red floral pattern in silk for the front cover.  My teacher, expecting a stapled stack of papers, was pleasantly surprised.  Then, when she opened the book, she was astonished.  “It’s typed!” she cried.

“Well of course it’s typed,” I replied casually.  “I told you I was going to type it.”

The backstory – my Russian class

Before I get to the picture book itself, it should be useful and amusing for you to read about my Russian class and how the personalities involved shaped my story.  During my junior year, I decided to take Russian simply because I’d been studying French since 7th grade and was kind of burned-out on it.  Most of the other kids in my class chose Russian because it had the reputation for being the easiest foreign-language class on offer—an “easy C.”  This was because there was only one teacher, Илена Нетровна, who was the nicest old lady on the planet.  (I haven’t changed any names in this post, because throughout I’ve used our classroom Russian names.  Нетровна isn’t my teacher’s last name, but her patronymic—literally, “daughter of Peter.”)  During a test, you could wave Илена Нетровна over and flat-out ask for the answer and she’d give it to you.  She didn’t have the heart to leave a student behind, so we learned at a tectonic pace.  (Russian is easy to begin with, because it is such a logical and consistent language, and much easier to pronounce than, say, French.)

My class was like the band of misfits you’d find in a teen coming-of-age movie.  There was Тимофей, a leather-jacket-clad punk rocker whose bleached hair was arranged in corn-rows and set in epoxy; his female counterpart Маша, whose hair was also bleached but merely swooped straight up (I had the hots for her); Матвей, a pal of mine I feared had a drinking problem (but then, I was a goody two-shoes type; in England he’d probably have been thought a “hale fellow well met”); and Адам, a very small dude (dare I say Fun-Size?) with an outsized knack for troublemaking.  There were others who were much better students, the best being Катя, who was really nerdy but kind of attractive, and who was cursed with a nickname so cruel I won’t repeat it here (hint:  it combined her reputation as a nerd with an accusation of meretriciousness).

(An interesting aside:  the CIA came to our class to try to recruit us into an intensive language program, promising us exciting cold-war spy jobs where we’d eavesdrop on Soviet radio communications.  Nobody bit.) 

The first year passed with the whole class in lockstep, meaning that very little of the language was actually covered.  Perhaps for this reason, or perhaps because Илена Нетровна (phonetically “Elena Petrovna”) got tired of being disrespectfully called “Yilyenna” (which probably cannot even be rendered in Russian), we got a new teacher the next year, who was just out of college and commanded more of the guys’ attention.   (We were teenagers, so it didn’t take much.)  She decided that one half of the class was ready for harder work, so she split the class into Russian 2 and Russian 3, dividing her attention between the two groups.  The so-called Russian 2 students immediately renamed themselves “The Dumb Group,” and renamed Russian 3 “The Smart Group,” and (notwithstanding that I was technically in Russian 3) dubbed me the “Leader of the Dumb Group.”  I felt like Max in Where the Wild Things Are.

Why me?  Well, in that school district, at least at that time, being smart really was uncool and good grades could be the kiss of death socially.  So I tried to hide my good test scores, not just by covering them up, but by playing dumb.  Well, one day we got back a big test, and Катя bragged to a friend that she got like a 97%.  Somebody—it might have been the teacher, or somebody else who happened to see my paper—told Катя that I’d gotten a 100%, after which (the cat already being out of the bag) I ribbed her a bit about being beaten by a dumbass.  Maybe I ribbed her a bit too much—she got really flustered and I thought she was going to actually start crying.  I felt bad, but from that day forward I was like a hero to the Dumb Group:  a guy who could hold his own against the nerds while still being a troublemaker at heart.

Was I really a troublemaker?  I guess I was, though I can’t remember exactly how I misbehaved.  I must have, though, because one day the teacher (the new, young one) dragged me out of class into an empty classroom and chewed my head off.  She was really ticked, her face flushed, and then I noticed her undergoing another physiological effect that seemed inappropriate to the situation (a response usually associated with either cold weather or a specific stimulation unrelated to anger).  It was one of the most remarkable situations of my life to that point, and though I must have cleaned up my act somewhat, I can’t say I was totally inclined to turn over a new leaf.  I did work a lot harder, though, when we tried to read a chapter of Lermontov’s A Hero of Our Time (a brilliant novel) in the original Russian.  That effort seriously humbled me, and I guess I needed that.

Okay!  Onward!  As you read my picture book, you’ll surely pick up on my anti-elitist theme; it’s about as subtle as being struck across the face repeatedly with a frozen sea bass.  Obviously I was quite the little hypocrite; after all, what could be more showy and pompous than being the only kid in the class to type his story?

Лучше Девушка

Here is the first page of the story, exactly as it appears in the book:


That “139” in the corner must be an artifact of some glitch in my brother’s software.  I should have whited it out.  My name in the upper right, Юрий, pronounced “Yuri,” was my chosen Russian name (there being no real equivalent for Dana).  Since there’s a lot of wasted space with my full-page format, hereafter I’ve cropped the pictures a bit, resized the text for easier reading, and added the English translations.





I think “music classroom” is pretty klunky (though it’s a literal translation of what I wrote).  If my daughter’s friend had lived in Russia, perhaps she’d know a better term for this.


I guessed wrong on the Russian spelling of Scrabble.  It’s actually СкрЭбл.  (In my defense, we didn’t have the Internet back then.)  I probably made all kinds of mistakes in this book.  It’s kind of amazing my daughter’s friend could read it at all.




This page presented a particular challenge for the translator.  She said “soccer,” because that’s what футбол (or футболе in the accusative case) translates to.  And yet, Олег is quite obviously holding a football.  Needless to say the game of American football isn’t played in Russia.  Where is this story supposed to take place?  I never even considered this.  Looking back, I did a pretty half-assed job on this picture book, notwithstanding the great work others did on it.


Look at those shoes.  The sad thing is, I can’t draw any better today.



This bit about the Talented And Best club was a dig at an actual society (whether it was regional, national, or an assortment of individual clubs, I have no idea) called TAG, for Talented And Gifted.  To be a member was the ultimate stigma socially.  Right around the time I wrote this story, I got into some pretty hot water over TAG.  I had a really plum word processing job at the Boulder Community Hospital, typing lab procedure manuals into the computer and formatting them neatly.  (Before this, these manuals had been typed on a typewriter or handwritten, so it was impossible to update them.)  There was only one personal computer in the whole place, in the big boss’s office, which was fine when I started because the lab was between bosses so the office was empty.

Then they hired this blowhard who sat in there all day talking on the phone, never conducting hospital business, always working on something like getting his car fixed.  It was unpleasant to work with him breathing down my neck, and I wasn’t sure how much longer I could go on.  One day he got into an argument with his teenage kid, right there in the office while I was trying to work.  The argument was about TAG.  I’d most likely have kept my mouth shut, but then my boss dragged me into it.  “Say, Dana, you seem bright.  Have you been offered membership in TAG?”

I replied, “Yeah, I was invited.”  He asked if I accepted, and I said I had not.  He asked why, and—who knows, maybe this was intentional career suicide—I just couldn’t restrain myself from saying, “I think TAG is just a club for kids who don’t have any real friends.”  His kid broke in, “See, Dad?  See?  It’s just like I was sayin’!”  Needless to say I didn’t last long in that job after that.  I guess I really did belong in the Dumb Group.

Thursday, August 30, 2012

Almost Intelligent - Part I


NOTE:  This post is rated R for mild strong language.
Introduction

“Almost intelligent” might be a good name for somebody’s biography (or autobiography) but here I’m talking about artificial intelligence.  My last post described my experience chatting with an application called Cleverbot that tried to simulate human dialog convincingly.  Here, I’ll tackle the subject of AI language more generally, looking at speech recognition, natural language, and translation. 

Do we care?

If you really don’t care about AI at all, go read something else—or, better yet, read on to see why maybe you should care.

On the one hand, AI is very exciting.  As computers have become “smarter,” and easier to use, they’ve gotten so useful it’s hard to imagine how we ever did without them.  I’m thinking about Google, GPS and other mapping applications, package tracking, e-mail spam filters … the list goes on and on.

On the other hand, AI is a bit scary, and as a human I prefer to believe I could never be replaced by a computer.  I shudder at the thought that human behavior could be so unvarying and predictable that one day we’ll barely be better than a really good computer program.  I want my computer applications to get smart, but not too smart.

Voice recognition and natural language

There’s a button on the side of my smartphone that, when pressed, startles me by causing the speakerphone to say, “Say a command!”  I’m vaguely aware that my phone will respond to voice commands but have no interest in issuing them.  Most of the cool features of smartphones involve the silent, non-speech stuff you can do—e-mail, Internet browsing, etc.—as you’ll notice on the subway when half the people are silently tapping away.  (The popularity of texting—a way to privately communicate without being eavesdropped on by the person you’re ostensibly talking to face-to-face—is a classic example of how phones are becoming increasingly mute.)

That said, the iPhone’s voice-recognition application, Siri, seems to be making a bit of a splash.  (Nobody I know uses Siri yet, but I’m sure some will.)  This demo shows how Siri is pretty good at understanding speech and figuring out what you want it to do.  (I played with a Droid phone recently and it was also very good at typing for me as I spoke.)  The reviewer asks Siri, “Where can I have lunch?”  Siri replies, “I found fourteen restaurants whose reviews mention lunch.  Twelve of them are close to you.”  This seems easier than typing into Google on a little phone.  But the natural language feature isn’t perfect; the reviewer says, “How about downtown?” and Siri replies, “I don’t know what you mean by ‘how about downtown.’”

Perhaps Siri’s communication isn’t “connection-oriented”—that is, it doesn’t consider “how about downtown?” in the context of “Where can I have lunch?” but takes the two queries as totally discrete and unrelated.  If so, this is a major shortcoming. 

The reviewer tries again:  “I want to have lunch downtown.”  Siri replies, “I found 3 restaurants matching ‘downtown.’”  Useless!  Siri knows where the user is, geographically, but does not realize that “downtown” in this context pertains to location, not a restaurant’s name.  Here, Siri starts to look like a mere forwarder of requests, always passing the buck to Google instead of applying intelligence to the request.

Simple conversion of speech to text looks pretty good on Siri.  The reviewer dictated a message to it, and almost everything came out.  The notable exception was how Siri transcribed the reviewer’s spoken comment “I need to make some videos about the iPhone 4S.”  Siri typed, “I need to make some videos about the iPhone 4 ass.”  The reviewer doesn’t notice this gaff, telling the YouTube viewer, “There it is.  It figured out exactly what I wanted to say.”  Dangerous, don’t you think?  What if the reviewer meant to e-mail the text “S as in Sam” but actually e-mailed “ass as in Sam,” to his boss, Sam?

Not that Siri doesn’t try hard.  When the reviewer says, “Set a timer for 3 minutes,” Siri replies, “OK, I started a three-minute timer.  Don’t overcook that egg.”  Not bad.  Actually, it is bad.  For one thing, “that egg,” when spoken by Siri, comes out “ditek.”  Without the text on the screen you’d never understand what it said.  Meanwhile, it’s obvious that Siri is trying to be funny, and completely failing.  There’s nothing witty about Siri making a lame guess as to what the timer is for.  What’s worse, Siri could create the impression that three minutes is actually how long you should cook an egg.  In fact that’s not nearly enough time, and everybody knows an undercooked egg presents a salmonella risk.

A fundamental problem

Of course I’m nitpicking with the egg timer example, and (to a lesser extent) with the “ass” example, but they bring up an important point:  language, as one of the primary interfaces between humans, requires far more than just understanding what is heard and forming sentences in response.  Having a sanity-check reflex that keeps you from using words like “ass” in mixed company, and knowing whether your joke is actually funny, are complicated processes.  Verbal communication can be a minefield, especially for a computer application that stabs around in the dark.

Consider, for example, the old joke about the Texan who gets into Harvard.  While touring the campus, he asks a student, “Excuuuse me, can you tell me where the library’s at?”  The student replies haughtily, “Here at Haaarvard, we never end a sentence with a preposition.”  The Texan replies, “Okay, can ya tell me where the library’s at, asshole?”

Upon inspection, this exchange, though brief, is quite complex.  The Harvard student’s response to the Texan’s query shows a decision that might not occur to an AI application—that is, to a) not answer the question, and b) use the opportunity to deliver a scornful message about class and intellect.  The Texan’s comeback makes a statement about a) his refusal to be cowed, b) the difference between cultivation and innate intelligence.  Meanwhile, the joke as a whole counts on the listener enjoying an opportunity to feel superior to both Harvard students and Texans, while exulting in the surprise and wit of the punch line.  Worlds away from “Enjoy ditek.”

Maybe you think I’m overreaching here, that such nuance will never be expected of AI.  Maybe AI is just a tool to make machines more useful to humans, and little gaffs don’t matter much.  When a woman asks her husband, “Do these pants make my butt look fat?” he is instantly plunged into a terribly complicated interaction, because of his relationship to the woman.  So much hinges on his response.  If he says “yes” he’s obviously dead.  If he says “no” too vociferously, he seems patronizing.  He could try the reverse-psychology approach and say, “No, your butt makes your butt look fat,” but she better have a sense of humor and thick skin.  Or, he could ignore the question, or say, “Look, krill!”  Or he could say “yeahhh” lecherously (note that imparting this single syllable with the sense of “I want some of that!” is far beyond the current state of the art in AI voice synthesis).  But when a human asks Siri “Am I fat?” and gets back, “Here’s your a.m. alarm” and “I found 8 fitness centers fairly close to you,” he or she can more easily blow it off.

This idea—that computers don’t have to play nice when “talking” to humans—is strongly supported by a scene in “The Terminator” when the evil cyborg, confronted by his landlord—“Hey buddy, you got a dead cat in there, or what?”—scans through a menu of possible responses—“YES/NO; OR WHAT; GO AWAY; PLEASE COME BACK LATER; FUCK YOU, ASSHOLE; FUCK YOU”—and chooses the penultimate one.  Of course when you’re the size of Arnold Schwarzenegger you don’t have to have a friendly user interface.

That said, I would argue that, to the extent humans are to embrace AI when using electronic devices, precision and nuance do matter.  We have to trust these devices not to turn “S” into “ass,” not to waste our time with lists of restaurants we’d never eat at, and not to infuriate us with messages like “cannot undo.”  Even if you’ve never found yourself yelling profanities at your computer, I’m sure you’ve seen others do it.

Consider this cautionary tale.  My dad bought one of the first consumer-oriented computers in history, the Hewlett-Packard Model 85.  This was 1980, a year before the IBM PC.  the HP-85 was about as far from Siri (or at least the design intent of Siri) as you can get.  There was no software for it; you had to program it yourself.  Meanwhile, its version of BASIC was proprietary, diverging from the industry standard (e.g., you used the command “DISP” instead of “PRINT”).  I had my brother try out one of my first programs.  It prompted him to type his name.  With great hesitation—he was greatly fearful of doing something wrong and damaging our dad’s expensive machine—he typed “Max.”  Then he sat there waiting for something to happen.  Nothing did, because my program didn’t say anything about hitting the Enter key when done.  Max looked a bit nervous.  “It’s not working!  It’s not doing anything!” he cried.  I told him to hit Enter.  When he did, the computer promptly displayed the message “Max is a jerk” (the whole point of my program).  Max got really angry and flustered and to this day does not use a computer.  This probably isn’t just because of my program; the HP-85 was less than user-friendly and doubtless gave Max the wrong impression of where home computing was going.

Translation

Here is where the AI picture is, to me, much rosier.  Early attempts at translation, like Alta Vista’s Babelfish, were a joke.  You pasted the foreign-language text into a window, gave it the language to translate it into, and then were presented with a salad of translated words (with un-translated ones sprinkled like croutons) that made no sense at all.  The only real use for this tool was translating things into Tristan.

What’s Tristan?  Well, I used to have a colleague, a computer programmer, whose native-tongue language skills were so poor it was impossible to understand a thing he wrote.  His e-mails always gave my colleagues and me a laugh, and in his honor we invented a language and named it after him.  (It wasn’t really called Tristan, because his last name wasn’t really Tristan; I’ve changed it to protect him from possible embarrassment.)  To translate something into Tristan, you’d type normal text, translate it into French using Babelfish, and then translate it back to English.  The results were pure comedy, with not a shred of sense left intact.

I think people are naturally forgiving of poor translation, because we’ve studied grammar and foreign languages in school and can really appreciate how difficult a task this is.  Plus, the results are so often funny, they put us in a good mood.  Consider the urban legend that “Coca-Cola,” when first translated into Chinese, came out meaning “bite the wax tadpole.”  (To this day I’ll complain about something by saying it bites the wax tadpole.)  Brian Hayes, writing in “American Scientist,” makes an interesting comment about AI efforts to parse grammatical constructions when translating text:  “The failure of this approach is sometimes dramatized with the tale of the English→ Russian→ English translation that began with ‘The spirit is willing but the flesh is weak’ and ended with ‘The vodka is strong but the meat is rotten.’”

More recently, online translation engines such as Google Translate have gotten much, much better.  As Hayes describes, “The idea is to ignore the entire hierarchy of syntactic and semantic structures—the nouns and verbs, the subjects and predicates, even the definitions of words—and simply tabulate correlations between words in a large collection of bilingual texts.”  At first, this strikes me as a “brute force” approach that is further from artificial intelligence than earlier efforts, however hapless, to actually parse a sentence grammatically.  But as Hayes points out, the modern technique is actually lot closer to how humans learn to talk.  (It’s also more similar to how we would learn a foreign language if we had the good fortune to go live in another country, versus making our way with a textbook and classes.)

I first tried Google Translate when I was trying to track a package that was being shipped to me from a web merchant in France.  I have studied French for years, but understanding statements about logistics and customs offices would be difficult in any language.  I was presented with this:  “Votre colis est sorti du bureau d'échange.  Il est en cours d'acheminement dans le pays de destination.”  This would have totally tripped up the original Babelfish, but Google served up an entirely comprehensible translation:  “Your package is out of the office of exchange. It is in transit in the country of destination.”  (Not only was I delighted with how clear this was, I was relieved my package wasn’t stuck in customs.)  Translating this English back into French, and then back into English, I get “Your package is out of the office of exchange. It is in transit to the destination country.”  Very little of the “Tristan effect.”  (There’s some fuzziness around “to” vs. “in” with regard to the destination country, but I can live with that.)

To reassure myself then the Man of Letters wouldn’t be replaced by a machine anytime soon, I tried some poetry: 
But the Raven still beguiling all my sad soul into smiling,
Straight I wheeled a cushioned seat in front of bird and bust and door;
Then, upon the velvet sinking, I betook myself to linking
Fancy unto fancy, thinking what this ominous bird of yore—
What this grim, ungainly, ghastly, gaunt, and ominous bird of yore
Meant in croaking “Nevermore.”
When I fed this into the new version of Babelfish (which works similarly to Google’s), and translated it into French and back, the response was this: 
But the Raven seductive yet all my sad soul into smiling,
Straight I wheeled a seat padded before the bird and bust and door;
Then, on the Velvet sinking, I hauled myself to tie Fancy: fancy,
Think what this bird threatening of antan - the sad bird, awkward, frightening,
Ghent and disturbing past Meant in croaking “Nevermore.”
Aha!  Gibberish!  I was about to feel all smug about the superiority of humans over AI, but then tried Google Translation with the same English à French à English task: 
But the raven still beguiling all my sad soul into smiling,
 I wheeled a cushioned seat in front of bird and bust and door;
 Then, upon the velvet sinking me, I betook myself to linking
 Fancy unto fancy, thinking what this ominous bird of yore -
 What this grim, ungainly, ghastly bird, gaunt, and ominous of yesteryear
 Meant in croaking “Nevermore.”
Wow.  That’s so good it’s creepy.  But before you despair and decide the computers will ultimately render the human race unnecessary, be sure to check out my next albertnet post, wherein I examine how well AI does playing games—another classic measure of its progress.

Other albertnet posts on A.I.