paddle coredump exception fix (#807)

* paddle_null_point_fix

* add core expception note

* delete yield

* modify test paddle for supporting enable_paddle()
pull/814/head
JesseyXujin 5 years ago committed by Sun Junyi
parent dc2b788eb3
commit d703bce302

@ -298,8 +298,9 @@ class Tokenizer(object):
is_paddle_installed = check_paddle_install['is_paddle_installed']
sentence = strdecode(sentence)
if use_paddle and is_paddle_installed:
# if sentence is null, it will raise core exception in paddle.
if sentence is None or sentence == "" or sentence == u"":
yield sentence
return
import jieba.lac_small.predict as predict
results = predict.get_sent(sentence)
for sent in results:

@ -279,8 +279,9 @@ def cut(sentence, HMM=True, use_paddle=False):
"""
is_paddle_installed = check_paddle_install['is_paddle_installed']
if use_paddle and is_paddle_installed:
# if sentence is null, it will raise core exception in paddle.
if sentence is None or sentence == "" or sentence == u"":
yield pair(None, None)
return
import jieba.lac_small.predict as predict
sents, tags = predict.get_result(strdecode(sentence))
for i, sent in enumerate(sents):

@ -2,7 +2,7 @@
import sys
sys.path.append("../")
import jieba
jieba.enable_paddle()
def cuttest(test_sent):
result = jieba.cut(test_sent, use_paddle=True)

@ -2,7 +2,8 @@
import sys
sys.path.append("../")
import jieba.posseg as pseg
import jieba
jieba.enable_paddle()
def cuttest(test_sent):
result = pseg.cut(test_sent, use_paddle=True)

Loading…
Cancel
Save