示例#1
0
def evaluate_mlp_ner():
    cws = DNN('mlp', mode=TrainMode.Sentence, is_seg=True, task='ner')
    model = 'tmp/mlp/mlp-ner-model1.ckpt'
    # print(cws.seg('在中国致公党第十一次全国代表大会隆重召开之际,中国共产党中央委员会谨向大会表示热烈的祝贺,向致公党的同志们', model,ner=True))
    print(cws.seg('多饮多尿多食', model, ner=True))
    print(cws.seg('无明显小便泡沫增多,伴有夜尿3次。', model, ner=True))
    print(cws.seg('无明显双脚疼痛,无间歇性后跛行,无明显足部红肿破溃', model, ner=True, debug=False))
示例#2
0
def evaluate_mlp():
    cws = DNN('mlp', mode=TrainMode.Sentence)
    model = 'tmp/mlp-model20.ckpt'
    # print(cws.seg('小明来自南京师范大学', model, debug=True))
    # print(cws.seg('小明是上海理工大学的学生', model))
    # print(cws.seg('迈向充满希望的新世纪', model))
    # print(cws.seg('我爱北京天安门', model))
    # print(cws.seg('在中国致公党第十一次全国代表大会隆重召开之际,中国共产党中央委员会谨向大会表示热烈的祝贺,向致公党的同志们',model))
    print(cws.seg('多饮多尿多食', model))
    print(cws.seg('无明显小便泡沫增多,伴有夜尿3次。', model))
    print(cws.seg('无明显小便泡沫增多,伴有夜尿3次。', model, ner=True))
    print(cws.seg('无明显双脚疼痛,无间歇性后跛行,无明显足部红肿破溃', model))
示例#3
0
def get_ner(content, model_name):
    if model_name.startswith('tmp/mlp'):
        dnn = DNN('mlp', mode=TrainMode.Sentence, task='ner', is_seg=True)
    else:
        dnn = DNN('lstm', task='ner', is_seg=True)
    ner = dnn.seg(content, model_path=model_name, ner=True, trans=True)
    return ner[1]
示例#4
0
def evaluate_lstm():
    cws = DNN('lstm', is_seg=True)
    model = 'tmp/lstm-model100.ckpt'
    print(cws.seg('小明来自南京师范大学', model, debug=True))
    print(cws.seg('小明是上海理工大学的学生', model))
    print(cws.seg('迈向充满希望的新世纪', model))
    print(cws.seg('我爱北京天安门', model))
    print(cws.seg('多饮多尿多食', model))
    print(cws.seg('无明显小便泡沫增多,伴有夜尿3次。无明显双脚疼痛,无间歇性后跛行,无明显足部红肿破溃', model))
示例#5
0
def get_cws(content, model_name):
    dnn = DNN('mlp', mode=TrainMode.Sentence, task='ner')
    ner = dnn.seg(content, model_path=model_name, ner=True, trans=True)[1]
    return ner