#1 classifier problem

closed
nobody
None
5
2014-08-18
2004-04-12
Anonymous
No

I'm having a problem with the classifier module of NLTK
1.2. Specifically, I
keep getting this error:

>>> fd_list = BagOfWordsFDList(word_list, labels)

Traceback (most recent call last):
File "<pyshell#5>", line 1, in -toplevel-
fd_list = BagOfWordsFDList(word_list, labels)
NameError: name 'BagOfWordsFDList' is not defined

Both "word_list" and "labels" were created successfully,
and I have done "from
nltk.classifier import *", so I don't see why it's not
finding the
BagOfWordsFDList function. There also seems to be a
problem with the Numeric module. Do you have any
ideas? (I'm running this on a Windows 2000 machine.)

Thanks,
-Emily

Discussion

  • Edward Loper
    Edward Loper
    2004-04-24

    Logged In: YES
    user_id=195958

    The BagOfWordsFDList is defined by
    nltk.classifier.feature. In python, doing:

    from <package> import *

    only imports names defined directly in that package, and
    not names defined in subpackages. So add the following
    import:

    from nltk.classifier.feature import *

    and that should import BagOfWordsFDList for you.

    Numeric doesn't come with Python, and needs to be
    installed separately. You can download a windows
    installer from here:

    http://sourceforge.net/project/showfiles.php?
    group_id=1369&package_id=1351

    Note that the people who wrote "Numeric" are replacing it
    with a new module named "Numarray". But NLTK 1.2 was
    written to use Numeric, not Numarray. (NLTK 1.4 will use
    Numarray.)

     
  • Edward Loper
    Edward Loper
    2004-04-24

    • status: open --> closed