Python jieba 模块,del_word() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用jieba.del_word()

项目:HtmlExtract-Python    作者:xinyi-spark    | 项目源码 | 文件源码
def del_word_dict(word):
    '''
    ????????
    '''
    jieba.del_word(word)
项目:slack_emoji_bot    作者:linnil1    | 项目源码 | 文件源码
def __init__(self, slack, custom):
        self.slack = slack
        self.rundata = custom['data']
        self.colorPrint = custom['colorPrint']

        self.food_dir = "data/midnight.json"
        self.food_dic = "data/dict.txt.big"

        # find midnight channel
        self.nochannel = False
        rep = self.slack.api_call("channels.list")
        self.channel_id = ""
        for c in rep['channels']:
            if c['name'].lower() == custom['food_channelname']:
                self.channel_id = c['id']
                break
        if not self.channel_id:
            self.colorPrint(
                "No midnight channel",
                "Restart when midnight channel can use",
                color="FAIL")
            self.nochannel = True
            return

        jieba.set_dictionary(self.food_dic)
        jieba.initialize()

        # add and del words
        for word in self.rundata.get('FOOD_addword'):
            jieba.add_word(word)
        for word in self.rundata.get('FOOD_delword'):
            jieba.del_word(word)

        self.init()
项目:slack_emoji_bot    作者:linnil1    | 项目源码 | 文件源码
def main(self, datadict):
        if self.nochannel:
            return
        if datadict['type'] == 'message' and \
                datadict.get('subtype') == "file_share" and \
                datadict.get('channel') == self.channel_id:
            self.imageAdd(datadict['file'])
        if not datadict['type'] == 'message' or 'subtype' in datadict:
            return
        if datadict['text'].startswith("food "):
            text = re.search(
                r"(?<=food ).*", datadict['text'], re.DOTALL).group().strip()

            payload = {
                "username": "?? Midnight",
                "icon_emoji": ":_e9_a3_9f:",
                "thread_ts": datadict.get("thread_ts")or'',
                "channel": datadict['channel']}

            try:
                ans = self.wordSearch(text)

                self.slack.api_call("chat.postMessage",
                                    attachments=[self.wordParse(ans)],
                                    **payload
                                    )
            except BaseException:
                self.slack.api_call("chat.postMessage",
                                    text="Sorry Not Found",
                                    **payload
                                    )

        elif datadict['text'].startswith("foodadd "):
            text = re.search(r"(?<=foodadd ).*",
                             datadict['text']).group().strip()
            jieba.add_word(text)
            self.rundata.append("FOOD_addword", text)
            self.init()
        elif datadict['text'].startswith("fooddel "):
            text = re.search(r"(?<=fooddel ).*",
                             datadict['text']).group().strip()
            jieba.del_word(text)
            self.rundata.append("FOOD_delword", text)
            self.init()