What is the most efficient way to get the past tense of a verb, preferably without using memory heavy NLP frameworks?
e.g.
I wrote something quick myself (stack overflow won't let me self answer) which seems to work for regular verbs (e.g. the first 4 of that list), but not irregular verbs: http://pastebin.com/Txh76Dnb
edit: Thanks for all the responses, it looks like it can't be done properly without a dictionary due to irregular verbs.
While I wanted to do this algorithmically without using dictionaries, I had to resort to using one.
I found that the most efficient library was SimpleNLG.
Since their docs are out of sync with the current API, here is how to achieve this:
XMLLexicon lexicon = new XMLLexicon("path\\to\\default-lexicon.xml");
WordElement word = lexicon.getWord("live", LexicalCategory.VERB);
InflectedWordElement infl = new InflectedWordElement(word);
infl.setFeature(Feature.TENSE, Tense.PAST);
Realiser realiser = new Realiser(lexicon);
String past = realiser.realise(infl).getRealisation();
System.out.println(past);
One way to go might be to create a dictionary of just irregular verbs (those that don't follow the usual pattern), and then lookup the word first in that. If the word doesn't appear, use your algorithm. Does anyone know the relative numbers of regular vs irregular verbs in English?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With