¡Feliz Navidad!
I started this spare time project in the vain hope that I might be able to aid my child process in learning how to conjugate Spanish verbs. I'm about halfway through and starting to run out of steam, so I'm putting it out for comments and making it available on Github in case anyone might find it useful.
The API consists of one sub, conjugate, which takes 4 arguments, the infinitive of the verb, the tense, the person and the number, so for the third person plural, present tense of the verb "dormir" would be produced with
conjugate('dormir', 'present', 3, 2) and should return "duermen". Regular verbs are available for most tenses except perfect and progressive because those involve more than just changing a stem and adding the appropriate ending. There is a TODO list in the project which lets you know what doesn't work, but the best indicator of what does work is the test suite. That's been the big slog and will be the most valuable part of this module. I have over 300 tests now (about a third of what's needed)
This first attempt is just a prototype to see where the pitfalls are and as a result, the code design has grown organically to handle exceptions. I'm wondering if I'm going down hard-to-maintain path if I continue like this, so any suggestions on how to change stems, endings, prefixes, accents and deal with spelling changes to preserve pronunciation would be gratefully received.
Without any further ado, here's all 653 lines:
package Lingua::ES::Conjugate;
use Carp;
use Storable qw(dclone);
require Exporter;
our @ISA = qw(Exporter);
use warnings;
use strict;
my @AR_present = qw( o as a amos áis an );
my @ER_present = qw( o es e emos éis en );
my @IR_present = qw( o es e imos ís en );
my @AR_preterit = qw( é aste ó amos asteis aron );
my @ER_preterit = qw( í iste ió imos isteis ieron );
my @IR_preterit = @ER_preterit;
my @AR_imperfect = qw( aba abas aba ábamos abais aban );
my @ER_imperfect = qw( ía ías ía íamos íais ían );
my @IR_imperfect = @ER_imperfect;
my @AR_subjunctive = qw( e es e emos éis en );
my @ER_subjunctive = qw( a as a amos áis an );
my @IR_subjunctive = @ER_subjunctive;
my @future = qw( é ás á emos éis án );
my @conditional = qw( ía ías ía íamos íais ían );
my $AR_pastparticiple = 'ado';
my $ER_pastparticiple = 'ido';
my $IR_pastparticiple = $ER_pastparticiple;
my $AR_gerund = 'ando';
my $ER_gerund = 'iendo';
my $IR_gerund = $ER_gerund;
my @AR_imperitive = qw( a ad ); # tu habla, vosostros hablad, need for
+mal and negative
my @ER_imperitive = qw( e ed ); # tu habla, vosostros hablad, need for
+mal and negative
my @IR_imperitive = qw( e id ); # tu habla, vosostros hablad, need for
+mal and negative
I had thought about putting it up for the Google's Code-in contest for teens, but I don't have time to mentor anyone.
Anyways, thanks for looking