Error: Class advice impossible in Python3 topia.termextract
Asked Answered
X

2

6

I am performing an nlp task. I have written the following code for topia.termextract. While executing it isshowing errors. It will be helpful, if you suggest to resolve the errors.

from topia.termextract import extract
from topia.termextract import tag

# Setup Term Extractor
extractor = extract.TermExtractor()

# Some sample text
text ='''
Police shut Palestinian theatre in Jerusalem.

Israeli police have shut down a Palestinian theatre in East Jerusalem.

The action, on Thursday, prevented the closing event of an international
literature festival from taking place."""

# Extract Keywords
keywords_topica = extractor(text)
print(keywords_topica)

I am using Python 3 in google colab.

---------------------------------------------------------------------------      
TypeError                                 Traceback (most recent call last)      
<ipython-input-23-9a094f024dfe> in <module>()      
 ----> 1 from topia.termextract import extract    
       2 from topia.termextract import tag     

 3 frames      
 /usr/local/lib/python3.6/dist-packages/zope/interface/declarations.py in implements(*interfaces)    
     481     # the coverage for this block there. :(     
     482     if PYTHON3:     
 --> 483         raise TypeError(_ADVICE_ERROR % 'implementer')    
     484     _implements("implements", interfaces, classImplements)    
     485      

     TypeError: Class advice impossible in Python3.  Use the @implementer class decorator instead.     
Xylography answered 14/12, 2019 at 6:12 Comment(1)
Hello, Did you figure this out? The answer provided didnt help.Ligate
H
4

To solve this, I added the following line:

from zope.interface import implementer

to both:

~/.local/lib/python3.8/site-packages/topia/termextract/extract.py

and:

~/.local/lib/python3.8/site-packages/topia/termextract/tag.py

.

Then in extract.py, I changed

class TermExtractor(object):
    zope.interface.implements(interfaces.ITermExtractor)

to:

@implementer(interfaces.ITermExtractor)
class TermExtractor(object):
    ...

And similarly, in tag.py,

class Tagger(object):
    zope.interface.implements(interfaces.ITagger)

to:

@implementer(interfaces.ITagger)
class Tagger(object):
    ...

Hope this helps!

Holeproof answered 11/7, 2020 at 13:13 Comment(2)
says implementer is not defined.Jurisprudent
should add from zope.interface import implementer to tag and extract files.Jurisprudent
S
0

Below steps solved the issue for me,

pip uninstall apex
git clone https://www.github.com/nvidia/apex
cd apex
python3 setup.py install
Sade answered 6/5, 2020 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.