On Fri, Feb 5, 2010 at 12:29 PM, Owain Clarke <simb...@cooptel.net> wrote:

>
>
>   Seems to be a bit of a consensus here about dictionaries.  Let me just
> restate my reluctance, using examples from Spanish.
>
> esperar = to hope
> esperar = to wait
> tambien = too [i.e. also]
> demasiado = too [i.e. excessive]
>
> So there are repeats in both languages.  I would like to end up with a file
> which I can use to generate flash cards, either to or from English, and I
> suppose I want the flexibility to have 1 word with 1 definition.
>
>
I'd use a database table to handle the many-to-many relationships between
English words and Spanish words. You can use the lightweight SQLite database
engine, which comes with Python (http://docs.python.org/library/sqlite3.html
).

The table would have just two columns: one for the English word and one for
the Spanish word. Each row represents a possible association of an English
word with a Spanish word.

    en              es

    dream        soñar
    hope          esperar
    wait           esperar
    too            también
    too            demasiado


With a table structured like this, you can retrieve all the English words
associated with a particular Spanish word, or all the Spanish words
associated with a particular English word.

For example, with the data above, stored in a table named 'translation' with
columns named 'en' and 'es', the following SQL query,

select en from translations where es = 'esperar'

... would return:

hope
wait


--
Emmanuel
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to