Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get the past tense of a verb? [closed]

Tags:

java

nlp

What is the most efficient way to get the past tense of a verb, preferably without using memory heavy NLP frameworks?

e.g.

  • live to: lived
  • try to: tried
  • tap to: tapped
  • boil to: boiled
  • sell to: sold

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.

like image 926
Richard EB Avatar asked Mar 01 '12 16:03

Richard EB


2 Answers

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);
like image 159
Richard EB Avatar answered Oct 04 '22 16:10

Richard EB


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?

like image 23
stw Avatar answered Oct 04 '22 15:10

stw