diff --git a/jieba/__init__.py b/jieba/__init__.py index 2a72ca0..826b5d8 100644 --- a/jieba/__init__.py +++ b/jieba/__init__.py @@ -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: diff --git a/test/test_cut_for_search.py b/test/test_cut_for_search.py index 51f82a4..47cd354 100644 --- a/test/test_cut_for_search.py +++ b/test/test_cut_for_search.py @@ -90,4 +90,8 @@ if __name__ == "__main__": cuttest('一次性交多少钱') cuttest('两块五一套,三块八一斤,四块七一本,五块六一条') cuttest('小和尚留了一个像大和尚一样的和尚头') - cuttest('我是中华人民共和国公民;我爸爸是共和党党员; 地铁和平门站') \ No newline at end of file + cuttest('我是中华人民共和国公民;我爸爸是共和党党员; 地铁和平门站') + cuttest('张晓梅去人民医院做了个B超然后去买了件T恤') + cuttest('AT&T是一件不错的公司,给你发offer了吗?') + cuttest('C++和c#是什么关系?11+122=133,是吗?PI=3.14159') + cuttest('你认识那个和主席握手的的哥吗?他开一辆黑色的士。') \ No newline at end of file diff --git a/test/test2.py b/test/test_cutall.py similarity index 92% rename from test/test2.py rename to test/test_cutall.py index b267bc5..c1cefc3 100644 --- a/test/test2.py +++ b/test/test_cutall.py @@ -90,4 +90,8 @@ if __name__ == "__main__": cuttest('一次性交多少钱') cuttest('两块五一套,三块八一斤,四块七一本,五块六一条') cuttest('小和尚留了一个像大和尚一样的和尚头') - cuttest('我是中华人民共和国公民;我爸爸是共和党党员; 地铁和平门站') \ No newline at end of file + cuttest('我是中华人民共和国公民;我爸爸是共和党党员; 地铁和平门站') + cuttest('张晓梅去人民医院做了个B超然后去买了件T恤') + cuttest('AT&T是一件不错的公司,给你发offer了吗?') + cuttest('C++和c#是什么关系?11+122=133,是吗?PI=3.14159') + cuttest('你认识那个和主席握手的的哥吗?他开一辆黑色的士。') \ No newline at end of file