# coding: utf-8 import pynlpir from pynlpir import nlpir nlpir.Init(nlpir.PACKAGE_DIR, nlpir.UTF8_CODE, None) nlpir.SetPOSmap(3) f = open(‘D:/article.txt‘) s = f.read() print nlpir.ParagraphProcess(s, True) f.close()
# coding: utf-8 import pynlpir from pynlpir import nlpir nlpir.Init(nlpir.PACKAGE_DIR, nlpir.UTF8_CODE, None) nlpir.SetPOSmap(3) nlpir.NWI_Start() rs = nlpir.NWI_AddFile(‘D:/article.txt‘) nlpir.NWI_Complete() # li = nlpir.NWI_GetResult(rs) nlpir.NWI_Result2UserDict(rs) #print li
#nlpir.py #New Word Identification NWI_Start = get_func(‘NLPIR_NWI_Start‘,restype=c_bool) NWI_AddFile = get_func(‘NLPIR_NWI_AddFile‘,[c_char_p], c_bool) NWI_AddMem = get_func(‘NLPIR_NWI_AddMem‘,[c_char_p], c_bool) NWI_Complete = get_func(‘NLPIR_NWI_Complete‘, restype=c_bool) NWI_GetResult = get_func(‘NLPIR_NWI_GetResult‘,[c_int], c_char_p) NWI_Result2UserDict = get_func(‘NLPIR_NWI_Result2UserDict‘,restype=c_uint)
时间: 2024-10-21 03:19:14