hot fix of cut_all=True

This commit is contained in:
Sun Junyi 2013-04-27 10:23:01 +08:00
parent 59d5d3b811
commit 94d455b079
3 changed files with 16 additions and 4 deletions

View File

@ -209,8 +209,12 @@ def cut(sentence,cut_all=False):
if x.strip(' ')!='':
yield x
else:
for xx in x:
yield xx
if not cut_all:
for xx in x:
yield xx
else:
yield x
def cut_for_search(sentence):
words = cut(sentence)
for w in words:

View File

@ -90,4 +90,8 @@ if __name__ == "__main__":
cuttest('一次性交多少钱')
cuttest('两块五一套,三块八一斤,四块七一本,五块六一条')
cuttest('小和尚留了一个像大和尚一样的和尚头')
cuttest('我是中华人民共和国公民;我爸爸是共和党党员; 地铁和平门站')
cuttest('我是中华人民共和国公民;我爸爸是共和党党员; 地铁和平门站')
cuttest('张晓梅去人民医院做了个B超然后去买了件T恤')
cuttest('AT&T是一件不错的公司给你发offer了吗')
cuttest('C++和c#是什么关系11+122=133是吗PI=3.14159')
cuttest('你认识那个和主席握手的的哥吗?他开一辆黑色的士。')

View File

@ -90,4 +90,8 @@ if __name__ == "__main__":
cuttest('一次性交多少钱')
cuttest('两块五一套,三块八一斤,四块七一本,五块六一条')
cuttest('小和尚留了一个像大和尚一样的和尚头')
cuttest('我是中华人民共和国公民;我爸爸是共和党党员; 地铁和平门站')
cuttest('我是中华人民共和国公民;我爸爸是共和党党员; 地铁和平门站')
cuttest('张晓梅去人民医院做了个B超然后去买了件T恤')
cuttest('AT&T是一件不错的公司给你发offer了吗')
cuttest('C++和c#是什么关系11+122=133是吗PI=3.14159')
cuttest('你认识那个和主席握手的的哥吗?他开一辆黑色的士。')