I recently worked on an Asturian spell checker and Asturian's verbal system very closely resembles Spanish (rather obviously, both being Iberian Romance languages).
In both, the irregularity of a verb presents itself in only a handful of ways, that may overlap in some places:
- first person singular of the present indicative
- same stem used in present subjunctive (exceptions: saber/ser/ir/haber/estar)
- stem changing (alternancia vocálica) in present indicative/subjunctive, and simple preterite, simple pluperfect indicative / imperfect subjunctive)
- simple preterite
- irregulars use the “regular irregular” endings (-e, -iste, -o, -imos, -isteis, -ieron)
- future indicative / conditional
What I did was create these groups and work with them individually. Here's how I laid them out for Asturian, visually (in reality, the first and second plural of present indicative should have a different color because they don't stem-change, but for the way I was processing things, they could be combined in my system)
The next step was to create a list of irregular verb types (mentioned above), and then process each of the colored groups individually based on those characteristics. For example, the teal shaded boxes are the subjunctive stem which is affected by first person singular irregularities, or, in the absence thereof, by stem changes. The logic then goes for the teal (stem1) and green (stem2) sections:
given verb, tense, mood, person, number
if(tense == pres &&
(mood == subj || (mood == ind && person == first && number == sing)
) {
// teal colored boxes
if(verb has irregularSubjStem) {
// subjunctive isn't 'just' the so-called opposite ending
if(verb has uniqueYoForm) return verb's irregularUniqueYoForm
// ^^ that is, voy/soy/sé, etc
stem1 = verb's irregularSubjStem;
// pong/teng/conozc/quep/etc
stem2 = verb's irregularSubjStem;
}else{
if(verb has stemChange) {
stem1 = stem's firstStemChange
// "duerm", "comienz", "prefier"
if(verb is IR) {
stem2 = stem's secondStemChange
// "durm", "prefir", "sirv" etc
}else{
stem2 = stem
}
}else{
stem1 = stem
stem2 = stem
}
}
if(verb is AR) {
vowel = e
else{
vowel = a
}
if(mood == ind) return stem + "o"
// quep + o, pong + o, comienz + o, nad + o
// mood is now necessarily subj
if(person == sing && (number == first) return stem1 + vowel
if(person == sing && (number == second) return stem1 + vowel + "s"
if(person == sing && (number == third) return stem1 + vowel
if(person == pl && (number == first) return stem2 + vowel + "mos"
if(person == pl && (number == second) return stem2 + vowel + "´is"
if(person == pl && (number == third) return stem1 + vowel + "n"
// ´ should be a combining acute (U+0301)
// otherwise you get, e.g., "ponga´is"
}
Note that this code is not remotely optimized nor runnable — I actually was working the opposite way (conjugation → infinitive) for my spell checker so there may be some better ways for going infinitive → conjugation, but it'll work. You could then have a much smaller file of truly irregular forms (present tense indicative ser, for instance).
That said, you still need to come up with methods of looking up what verb is stem changing, what its change is, as well as a number of orthographic changes:
- verbs that end in -car (-qu-), -gar (-gu-), -guar (-gü-), -zar (-c-), -quer (-c-), -quir (-c-), -guer (-g-), -güer (-gu-), -guir (-g-), -güir (-gu-), -cer (-z-), or -cir (-z-)
- conjugations resulting in an intervocalic -i- (-y-).
- conjugations resulting in diphthongized -i- after ñ or ll (-i- is elided)
- verbs that form explicitly indicate presence/absence of hiatus between stem and ending in the present tense singular and third-person plural: envío not *envio, but premia not *premía
If you want to go into adding on object pronouns (for use in commands and, if you're adventurous, very formal Spanish everywhere else), you'll need to factor in the loss of -s or -d in reflexive plural for first and second person (sentémonos not *sentémosnos and fijaos not *fijados as well as marking the accent where necessary. Also, not all object pronouns can go with all verbs. But to go that far, you'd need to also keep a list of the transivity and reflexivity of all verbs, a quite monumental undertaking that even I haven't done for Asturian.
Also, some verbs have multiple conjugations. Off the top of my head, placer randomly has both plació/placieron and plugo/pluguieron but doesn't have plugue/pluguiste/pluguimos/pluguisteis as would be expected. yacer has three subjunctive stems: yazc-, yazg-, yag-. erguir can be either an e→ie or e→i stem changing verb resulting in either irgo or yergo.
Other verbs are only valid in certain numbers/persons/tenses (called "defective verbs") The most common ones exist only in third person (and some only in third person singular) like weather words or acaecer or acontecer. Others like soler can only be used imperfectly (so no preterite or future, etc), or some of the weird -irs like abolir that traditionally are considered to only exist where the conjugation begins with i (so vos/vosotros can abolís, but tú/usted/ustedes can't *aboles, *abole, *abolen. yo can't *abolo, but we can *abolimos). Some of these are changing and becoming accepted, so YMMV. Some are super restricted. abarse only exists in the infintive and imperitive. These are much tougher to deal with and anytime you search for a comprehensive list of defective verbs, you'll always get slightly different answers, but with the exception of soler and weather words, they aren't verbs that the average Spanish learner will use often, or perhaps ever learn.
Needless to say, there's a lot to take into account for a perfect rendition of the Spanish conjugation system, but it shouldn't be remotely as hard to account for what 99.99% of Spanish learners will encounter.