APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Learning Spanish with a little help from Perl


2013/04/14

I had a very little bit of French in elementary school, two years of Latin in Junior High School and two more in High School, but the French is long forgotten and so is a lot of the Latin.

A while back I attempted Spanish with Rosetta Stone. That was a miserable failure - yes, I learned a few words, but not very many and, despite repeated attempts through the course, I remained unable to construct even a simple Spanish sentence, written or spoken.

That was disappointing. I shrugged and decided that perhaps it is true that you can't teach old dogs new tricks, but I wasn't happy about my failure.

Duolingo

I recently happened to catch a TED talk about Duolingo. While suitably impressed by the brilliance of the concept (you need to go watch that video to understand), I didn't have great hopes that Duolingo would help me any more than Rosetta Stone had. Still, nothing ventured, nothing gained, so I tried it.

Wow. I am impressed. In six weeks of Duolingo, I have actually begun to learn Spanish. I've written more about that at Forget Rosetta Stone - Duolingo is the best way to learn a language!; you could read that to see why I like it so much, or you can just go to Duolingo, create a free account and see for yourself. They have Spanish, French, Italian, German and (beta) Portugese as I write this - try it, it's free, it's fun and you WILL learn!

Forgetfulness

And, like the little bit of French I once learned, you will also forget. Duolingo does offer plenty of practice opportunities, but I wanted something I could tailor to my own needs, so, as usual, I turned to Perl.

My idea was to do something like flash cards. To that end, I created a file of Spanish and English sentences and sentence fragments. Whenever I come across something new, I add it to the file. When I get annoyed at seeing something that I've practised enough to never forget, I remove it. The file looks like this:


Le di un regalo a mi madre.| I gave my mother a gift.
A mis invitados siempre les ofrezco café.| I always offer coffee to my guests.
No les des comida a los animales.| Do not give food to the animals.
Siempre ofrezco café a mis invitados. | I always offer coffee to my guests.
I saw your dad at the store.|(Lo) vi a tu papá en la tienda.
The other day I met his wife. |El otro día (la) conocí a su esposa.
Ese regalo se lo di a él.|I gave him that gift.
I met Juan.|Conocí a Juan. 
Di un regalo a Juan.|I gave a gift to Juan.
Yes, it happens once in a while.| Sí ocurre de vez en cuando. (in when of time)
My boyfriend is a journalist.| Mi novio es un periodista.
Los sindicatos son grandes.| The unions are large.
Are you a victim?|¿Eres una víctima?
Do you know what I think of the Foundation?|¿Sabes qué pienso de la Fundación?
Tengo al individuo para usted.|I have the individual for you.
la huelga|the strike (union), be idle, loaf
We are the victims here.| Somos las víctimas aquí.
La muchacha tiene menos fruta que el hombre.|The girl has less fruit than the man.
Tengo una computadora pequeña.| I have a small computer.  In Spain it's called ordenador.
 

Of course it goes on for many more lines. I used "|" as a separator character to make my script less complicated - without that I'd have trouble knowing how to handle things like the last example. If I didn't have multiple sentences, I could split on periods, question marks and exclamations, but I didn't want to limit what I could add to the file.

The script simply presents random challenges. I could have written it where I'd need to type an answer, but I don't feel that's really necessary - if I can say the right words, that's enough. After all, I'm practising, not testing.

I also can type in specific words and it will show me things that match what I've typed. If I feel I need to refresh my memory of "para" and "por", I can type "for" and see results like this (I don't see the answer until I press Enter):

$ spanish.pl for
Cualquier día menos el lunes. 
 Any day except for Monday.

Thank you for the geography lesson. 
 Gracias por la clase de geografía.

Summer comes before the fall 
 El verano viene antes el otono.

I do not pay for my friends. 
 Yo no pago por mis amigos.

I want a battery for my car. 
 Quiero una batería para mi coche.

Meaning supporting or in favor of: Trabajamos por derechos humanos. 
 We work for human rights.
 

The script alternates between displaying the first part or the second and selects the lines randomly (if not searching for specific lines). The alternation is not random, but because the lines are, it effectively is. Therefore in one run I might be challenged with "Quiero una batería para mi coche." and in the other it might show "I want a battery for my car." instead.

By the way, searching for the special characters Spanish uses is not a problem: see How To Make Spanish Accents and Punctuation With a Mac. It's apparently a bit more difficult with Windows and Linux; see How To Make Spanish Accents and Punctuation in Ubuntu Linux for Linux and Using Your Keyboard To Make Spanish Accents and Punctuation in Windows for Windows.

The script itself should be easy enough to understand:

#!/usr/bin/perl
use List::Util 'shuffle';
$search=shift @ARGV;
open(I, "spanish");
@l=<I>;
while (1) {
 @l=shuffle(@l);
 #randomize the list
 foreach(@l) {
  next if not /$search/i;
  chomp;
  $x++;
  $x %=2;
  $y=1;
  $y=0 if $x == $y;
  @s=split /\|/;
  $s[0]=~s/^\s*//;
  $s[1]=~s/^\s*//;
  print "$s[$x] ";
  $n=<>;
  chomp $n;
  if ($n) {
    $search=$n;
  }
  print " @s[$y]" if not $n;
  print "\n";
  print "\n";
  }
 print "All done - end of list. Enter new search (or "." to clear searching. ";
 $n=<>;
 chomp $n;
 if ($n) {
   $search=$n;
 }
 }
 


Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> Learning Spanish with a little help from Perl


4 comments



Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Anthony Lawrence







Tue Apr 16 15:41:41 2013: 12030   BigDumbDinosaur

gravatar


Interesting that you mention your dismal results with Rosetta Stone. A friend's wife, whose in-laws are Italian, used Rosetta Stone to learn the language and according to my friend, achieved some degree of fluency. I suspect that Rosetta Stone's learning style doesn't fit yours as well.

Quiero una batería para mi coche.

The use of "coche" here is somewhat ambiguous. Depending on the region, a native speaker might literally understand the word to mean "coach," as in a horse-drawn vehicle, "bus," although the latter is generally referred to with "autobús," or "automobile," the latter which is usually referred to with "automóvil" or (commonly in Mexico) "carro." I can't say that I've ever heard "coche" used to refer to one's car, although it is technically correct.

Also, not to be picky, but numeric modifiers like "una" are usually omitted in casual conversation, especially when the modifier is "one," since in the absence of a modifier, one is assumed. If a modifier is used, it often follows the noun to which it refer, as such speech tends to flow better. So, your phrase could be:

"Quiero batería para carro mío."

If it were your laptop that needed a battery then you'd say:

"Quiero batería para computadora mía." More formal Spanish often uses "ordenador" to refer to a computer. Again, it's somewhat regional.





Tue Apr 16 16:54:24 2013: 12031   TonyLawrence

gravatar


It's funny: Duolingo is sometimes obsessive about un/una; probably to be sure you understand the necessity of matching gender. At other times, they won't complain.







Tue Apr 16 20:43:23 2013: 12033   BigDumbDinosaur

gravatar


Most of what I know of conversational Spanish was learned years ago while working with native speakers. Unfortunately, I've had virtually no reason to speak in Spanish in recent years. As language proficiency is achieved and maintained through constant use, my ability to hold a conversation in Spanish has greatly diminished.

The formal methods of learning a language can be very good at instilling grammar, word usage, etc., and in that regard, the modern computer has sure helped a bunch. I think any reasonably intelligent person who is truly motivated to learn a new language would be able to do so with suitable software. However, a computer can't make you think in the language you are learning, which really is the key to achieving proficiency and ultimately, complete fluency.

If you can directly convert your thoughts to Spanish instead of English then you will be able to carry on a conversation with a native speaker almost as if conversing in English. Knowing this implies that it takes frequent conversation with a native speaker to get to that level, unless you have a real knack for learning languages. So there is a bit of a chicken-and-egg situation involved.



Tue Apr 16 20:45:39 2013: 12034   TonyLawrence

gravatar


I think most language programs today offer the ability to talk with someone trying to learn the opposite of what you are learning..

------------------------
Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





Technology is both a tool for helping humans and for destroying them. This is the paradox of our times which we're compelled to face (Frank Herbert).

Standards are always out of date. That’s what makes them standards. (Alan Bennett)












This post tagged: