forked from HuangFJ/pyltp
-
Notifications
You must be signed in to change notification settings - Fork 350
Closed
Description
"Context managers allow you to allocate and release resources precisely when you want to. "
当前文档使用方法
from pyltp import Segmentor
segmentor = Segmentor() # 初始化实例
segmentor.load(cws_model_path) # 加载模型
words = segmentor.segment('元芳你怎么看') # 分词
print '\t'.join(words)
segmentor.release() # 释放模型
可否支持Context Manager,可以节省释放模型的过程
from pyltp import Segmentor
with Segmentor() as segmentor: # 初始化实例
segmentor.load(cws_model_path) # 加载模型
words = segmentor.segment('元芳你怎么看') # 分词
print('\t'.join(words))
Metadata
Metadata
Assignees
Labels
No labels