Python package package problem, missing function in utils file

python package package reference problem, missing function in utils file

AttributeError: "Utils" object has no attribute" init_utils"

the original text is here, how to use this function? Define another one yourself? Or do you have some skills? Shouldn"t it be executed automatically if it doesn"t start with self? As you are unfamiliar with the use of packages, please advise

class Utils(object):
    def __init__(self, utils_data=None):
        self.stopwords = self.init_utils(utils_data)

    def _init_utils(self, utils_data):
        for wd in utils_data["user_dict"]:
            jieba.add_word(wd)
        return set(utils_data["stopwords"])

    def _token_filter(self, token):  -sharp ; ; 
        return token not in self.stopwords and not token.isdigit() and len(token) >= 2

    def cut(self, text):
        return list(filter(self._token_filter, list(jieba.cut(text.lower()))))  -sharp 
< hr >

Summary afterwards:

I think the problem may be that when you make an external call, the assignment confuses list and dictionary, so I"ve removed _ before, which is not successful, but after straightening out the code, you can succeed. Or did I upgrade my ubuntu relationship in the middle? @ _ @, I don"t know, all kinds of possibilities, thank you for your attention!

Dec.30,2021

you need to put

in the constructor
 self.stopwords = self.init_utils(utils_data)
Change

to

 self.stopwords = self._init_utils(utils_data)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39ad8-2b92e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39ad8-2b92e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?