示例#1
0
def load_resources():
    from harvesttext.resources import get_qh_sent_dict, get_baidu_stopwords, get_sanguo, get_sanguo_entity_dict
    sdict = get_qh_sent_dict()  # {"pos":[积极词...],"neg":[消极词...]}
    print("pos_words:", list(sdict["pos"])[10:15])
    print("neg_words:", list(sdict["neg"])[5:10])

    stopwords = get_baidu_stopwords()
    print("stopwords:", list(stopwords)[5:10])

    docs = get_sanguo()  # 文本列表,每个元素为一章的文本
    print("三国演义最后一章末16字:\n", docs[-1][-16:])
    entity_mention_dict, entity_type_dict = get_sanguo_entity_dict()
    print("刘备 指称:", entity_mention_dict["刘备"])
    print("刘备 类别:", entity_type_dict["刘备"])
    print("蜀 类别:", entity_type_dict["蜀"])
    print("益州 类别:", entity_type_dict["益州"])
def test_load_resources():
    sys.stdout, expected = open(get_current_function_name()+"_current","w"), open(get_current_function_name()+"_expected").read()
    from harvesttext.resources import get_qh_sent_dict,get_baidu_stopwords,get_sanguo,get_sanguo_entity_dict
    sdict = get_qh_sent_dict()              # {"pos":[积极词...],"neg":[消极词...]}
    print("pos_words:",list(sdict["pos"])[10:15])
    print("neg_words:",list(sdict["neg"])[5:10])

    stopwords = get_baidu_stopwords()
    print("stopwords:", list(stopwords)[5:10])

    docs = get_sanguo()                 # 文本列表,每个元素为一章的文本
    print("三国演义最后一章末16字:\n",docs[-1][-16:])
    entity_mention_dict, entity_type_dict = get_sanguo_entity_dict()
    print("刘备 指称:",entity_mention_dict["刘备"])
    print("刘备 类别:",entity_type_dict["刘备"])
    print("蜀 类别:", entity_type_dict["蜀"])
    print("益州 类别:", entity_type_dict["益州"])

    sys.stdout.close()