标签:load red def name 加载 一个 imp div from
from pyhanlp import * def load_dictionary(): """ 加载HanLP中的mini词库 :return: 一个set形式的词库 """ IOUtil = JClass(‘com.hankcs.hanlp.corpus.io.IOUtil‘) path = HanLP.Config.CoreDictionaryPath.replace(‘.txt‘, ‘.mini.txt‘) dic = IOUtil.loadDictionary([path]) return set(dic.keySet()) if __name__ == ‘__main__‘: dic = load_dictionary() print(len(dic)) print(list(dic)[0])
IntroductionToNLP - ch02 - 2.2.2 词典的加载
标签:load red def name 加载 一个 imp div from
原文地址:https://www.cnblogs.com/hbuwyg/p/13155171.html