Wednesday, March 14, 2007

Verbs in Python

The French language has 46 irregular verbs. For some reason I think this number is much higher than in Italian and Spanish, but I could be wrong. Regardless, I asked my teacher why so many seemingly important verbs (i.e. to be, to go, to have, etc.) are irregular, and his answer was that irregularity was caused by verbs being used all them time.

A light came on in my head - perhaps the irregular verbs, the ones beginners tend to avoid, are the best verbs to start with since they are the most commonly used -- normally I would want to stick to the easily conjugatable 'regular' verbs, and handle the exceptions later on. Realizing that French has 46 irregular verbs, I figured this would be a chance to use my ability to talk to computers to improve my ability to talk to French people. The following code snippet is part of my quiz program which should invoke a smile in all those python lovers out there (non-techies: python is a programming language):

verbEndings = [
['ais', 'ais', 'ait', 'ions', 'iez', 'aient'], # imparfait
['ai', 'as', 'a', 'ons', 'ez', 'ont'], # future
['ais', 'ais', 'ait', 'ions', 'iez', 'aient'], # conditional
['e','es','e','ions', 'iez', 'ent'], # subj
['sse', 'sses', 't', 'ssions', 'ssiez', 'ssent'], # imparfait subj
]
verbData = {
'avoir':
[
'to have',
['ai', 'as', 'a', 'avons', 'avez', 'ont'],
['eu', 'avoir'],
'av',
'aur',
'eur',
['aie', 'aies', 'ait', 'ayons', 'ayez', 'aient'],
'eu',
],
'etre':
[
'to be',
['suis', 'es', 'est', 'sommes', 'etes', 'sont'],
['ete', 'avoir'],
'et',
'ser',
'ser',
['sois', 'sois', 'soit', 'soyons', 'soyez', 'soient'],
'fu',
],
...

I've actually stemmed all 46 irregular verbs, which the program can conjugate into:

- present
- past participle
- imperfect
- future
- conditional
- present subjunctive
- imperfect subjunctive

I just realized that I left out the imperative tense. I had assumed this was a clone of the subjunctive, but I should have known better. Sigh, more work to do.

No comments: