代码如下:
from LAC import LAC
def fenci():
lac = LAC(mode='seg')
text = u"LAC是个优秀的分词工具"
seg_result = lac.run(text)
print(seg_result)
texts = [u"LAC是个优秀的分词工具", u"百度是一家高科技公司"]
seg_result = lac.run(texts)
print(seg_result)
def cixingbiaozhuheshitishibie():
lac = LAC(mode='lac')
text = u"LAC是个优秀的分词工具"
lac_result = lac.run(text)
texts = [u"LAC是个优秀的分词工具", u"百度是一家高科技公司"]
lac_result = lac.run(texts)
print(lac_result)
def ciyuzhongyaoxing():
lac = LAC(mode='rank')
text = u"LAC是个优秀的分词工具"
rank_result = lac.run(text)
texts = [u"LAC是个优秀的分词工具", u"百度是一家高科技公司"]
rank_result = lac.run(texts)
print(rank_result)
def dingzhihua():
lac = LAC()
lac.load_customization('custom.txt', sep=None)
custom_result = lac.run(u"春天的花开秋天的风以及冬天的落阳")
print(custom_result)
if __name__ == '__main__':
参考文档如下:
https://github.com/baidu/lac/blob/master/python/README.md