mholtzscher / spacy_readability

spaCy pipeline component for adding text readability meta data to Doc objects.
MIT License
56 stars 10 forks source link

TypeError: __init__() takes 1 positional argument but 2 were given #115

Closed danielduckworth closed 5 years ago

danielduckworth commented 5 years ago

Description

I get the error: TypeError: init() takes 1 positional argument but 2 were given

What I Did

I ran the example in the docs.
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-44edc747c1a4> in <module>()
      3 
      4 nlp = spacy.load('en')
----> 5 read = Readability(nlp)
      6 nlp.add_pipe(read, last=True)
      7 

TypeError: __init__() takes 1 positional argument but 2 were given
mholtzscher commented 5 years ago

Looks like I had an error in the example documentation. I have pushed a fix onto the master branch with the change. Here is a colab notebook with the updated example as well. https://colab.research.google.com/drive/1NVl5rb2GBCTE0aGEzNtlBroUbaExHkC2

mholtzscher commented 5 years ago

Thanks for reporting this!

RoelTim commented 4 years ago

Hi @mholtzscher , I'm running into the same problem. The link to the colab notebook does not work anymore. Could you please share it again? Thank you, Roelien

SQLShark commented 4 years ago

For anyone who hits this in the future:

import spacy
from spacy_readability import Readability

nlp = spacy.load('en')
nlp.add_pipe(Readability())

doc = nlp("I am some really difficult text to read because I use obnoxiously large words.")

print(doc._.flesch_kincaid_grade_level)
print(doc._.flesch_kincaid_reading_ease)
print(doc._.dale_chall)
print(doc._.smog)
print(doc._.coleman_liau_index)
print(doc._.automated_readability_index)
print(doc._.forcast)
cvint13 commented 3 years ago

Hi,

Is this compatible with spacy v3? Now, you have to provide a name for nlp.add_pipe(). When I try running as per the documentation, I get the following error:

``ValueError: [E966]nlp.add_pipe` now takes the string name of the registered component factory, not a callable component. Expected string, but got <spacy_readability.Readability object at 0x000001997BCAC080> (name: 'None').

So I guess it needs to be updated? Or am I using it wrong?