1 #-*- encoding: utf-8 -*-
2 importNLPIR3 importos4
5 classC_NLPIR_ICTCLAS2013:6 def __init__(self,s_code='GBK'):7 dataurl = os.path.join(os.path.dirname(__file__))8 isinit =09 if s_code == 'GBK':10 isinit =NLPIR.NLPIR_Init(dataurl,NLPIR.GBK_CODE)11 elif s_code == 'UTF-8':12 isinit =NLPIR.NLPIR_Init(dataurl,NLPIR.UTF8_CODE)13 elif s_code == 'BIG5':14 isinit =NLPIR.NLPIR_Init(dataurl,NLPIR.BIG5_CODE)15 elif s_code == 'GBK_FANTI':16 isinit =NLPIR.NLPIR_Init(dataurl,NLPIR.GBK_FANTI_CODE)17 ifisinit:18 print 'NLPIR 初始化成功'
19 else:20 print 'NLPIR 初始化失败'
21
22 def stringSeg(self, s_string, i_bPOStagged=0):23 """
24 Function: Process one string;25 Parameters: @s_string - The string to be analyed,26 @i_bPOStagged: Judge whether need POS tagging, 0 for no tag; 1 for tag