0

What are the packages required to run the below commands?

Code

import nltk
from nltk.corpus import wordnet
v = 'go'
present = present_tense(v)
I got an error saying-

Error message

NameError: name 'present_tense' is not defined

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Apps
  • 529
  • 3
  • 8
  • 15
  • 1
    possible duplicate of [Using Nltk and Wordnet how do i convert simple tense verb into its present, past or past participle form?](http://stackoverflow.com/questions/3753021/using-nltk-and-wordnet-how-do-i-convert-simple-tense-verb-into-its-present-past) – Fred Foo Mar 29 '11 at 17:25
  • i picked up the commands from there. He hasn't mentioned the packages which need to be imported. Could you please help me? – Apps Mar 29 '11 at 17:35
  • Apps, they were asking how to implement a `present_tense` function, not importing an existing function. – Josh Rosen Mar 29 '11 at 22:24
  • The en package is the NodeBox English Linguistics Library, referenced in the comment by @larsmans – Jesuisme Jul 02 '14 at 10:43

1 Answers1

3

You may try: import en
instead of: import nltk

You may try: en.verb.present(v) instead of: present_tense(v)

The en package is from the NodeBox English Linguistics library

Demo site: http://wnbot.com/wordnet/stackoverflow.py

Draft source code listing:

#!/usr/bin/python

import en
import sys

went = 'went'
going = 'going'
gone = 'gone'
goes = 'goes'

print "Content-Type: text/html"
print
print "<html><head><title>Stack Overflow answer</title></head><body>"
print ' The present tense of <b>',going, '</b> is <i>',en.verb.present(going),'</i><br>'
print ' The present tense of <b>',goes, '</b> is <i>',en.verb.present(goes),'</i><br>'
print ' The present tense of <b>',gone, '</b> is <i>',en.verb.present(gone),'</i><br>'
print ' The present tense of <b>',went, '</b> is <i>',en.verb.present(went),'</i><br>'
print "</body></html>"

This source code listing is a draft for educational and discussion purposes only.

Jesuisme
  • 1,805
  • 1
  • 31
  • 41
Tom Joyce
  • 31
  • 2