-3

Here's the Site

From here i just try to ran the sample code provided on site, but am getting this error

enter image description here


TypeError Traceback (most recent call last) in ----> 1 text = nlp("The virginica species has the least average sepal_width.")

TypeError: 'NLP' object is not callable

I have installed all packages, but still what might have cause this issue?

Thirumalai vasan
  • 655
  • 2
  • 6
  • 19
  • yes i did! but still i got this issue! – Thirumalai vasan Jul 30 '20 at 12:46
  • 1
    Show more code. where is nlp defined in your code? if you imported the module nlp with "import nlp" that gets you an nlp namespace you still have to reference the items in that with the dot notation like nlp.somemethod() – LhasaDad Jul 30 '20 at 12:48

2 Answers2

1

Try that:

>>> from nlg.utils import load_spacy_model
>>> nlp = load_spacy_model()
>>> text = nlp("The virginica species has the least average sepal_width.")

I think the example author forgot to instantiate the nlp object, very common in spacy library. Consider reporting a issue in the nlg project.

Manoel Vilela
  • 844
  • 9
  • 17
1

from NLP import NLP is terrible code, because now the class (the second mention of NLP) will shadow the package. You won't be able to reference both of these. (It's also not great practice for the package name and its main class to be identically-named, but that's on the package author, not us programmers).

Much better to do this:

import NLP

# instantiate one
nlp = NLP.NLP()

# ... then do stuff with it
smci
  • 32,567
  • 20
  • 113
  • 146