python中yield的用法
https://blog.csdn.net/mieleizhi0522/article/details/82142856
class Find_words:
def __init__(self, min_count=10, max_count=100000):
self.min_count = min_count
self.max_count = max_count
self.total = 0.
def text_filter(self, texts):
for a in texts:
for t in re.split(u'[^\u4e00-\u9fa50-9a-zA-Z]+', a):
if t:
print('***')
yield t
def count(self, texts):
for text in self.text_filter(texts):
print(text)
if __name__ == '__main__':
fw = Find_words(1,100000)
all_sentences = ["大家好","我是小田老师","我来自中国"]
fw.count(all_sentences)
输出结果如下所示
***
大家好
***
我是小田老师
***
我来自中国