简体   繁体   中英

Type error while creating new logic adapter chatterbot

I am making a new logic adapter in my chatterbot-django project following documentation from https://chatterbot.readthedocs.io/en/stable/adapters/create-a-logic-adapter.html . when i run runserver command, it throws TypeError following is my adapter code:

from chatterbot.adapters.logic import LogicAdapter
from chatterbot.conversation import Statement
import wikipedia
class WikiAdapter(LogicAdapter):
    def __init__(self, **kwargs):
        super(WikiAdapter, self).__init__(kwargs)
    def can_process(self, statement):
        print(statement)
        if statement.text.startswith("#wiki"):
            return True

        return False
    def process(self, statement):
        request=statement.text[6:]
        confidence=1
        response=Statement(wikipedia.summary(request,sentences=3))
        return confidence,response

if i comment out the super command, no error is thrown. I dont know why it is working. Can anyone pls explain me

You are missing ** when you call super. It should be:

def __init__(self, **kwargs):
    super(WikiAdapter, self).__init__(**kwargs)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM