HanLP icon indicating copy to clipboard operation
HanLP copied to clipboard

pyhanlp在Debug断掉调试模型就会Python停止工作

Open whaozl opened this issue 8 years ago • 4 comments

注意事项

请确认下列注意事项:

  • 我已仔细阅读下列文档,都没有找到答案:
  • 我已经通过Google和issue区检索功能搜索了我的问题,也没有找到答案。
  • 我明白开源社区是出于兴趣爱好聚集起来的自由社区,不承担任何责任或义务。我会礼貌发言,向每一个帮助我的人表示感谢。
  • [x] 我在此括号内输入x打钩,代表上述事项确认完毕。

版本号

当前最新版本号是:1.6.8 我使用的版本是:1.6.8

我的问题

在使用pyhanlp过程中,如果是Debug模式,使用IDEA断点调试,就会出现Python停止工作 1

whaozl avatar Sep 07 '18 02:09 whaozl

你好,感谢反馈。 由于未按要求填写,本issue被自动关闭。请按issue模板认真填写,然后耐心等待下周末处理。 开源项目维护不易,只能在周末受理友好的提问,造成不便还望海涵。 issue

hankcs avatar Sep 07 '18 02:09 hankcs

感谢反馈,确认此问题存在。 由于JPype限制,目前无法在调用Java对象时下断点,但不影响其他场景下的断点。你可以简单包装一下:

from pyhanlp import *


def segment(text):
    return [(str(t.word), str(t.nature)) for t in HanLP.segment(text)]


for term in segment('商品和服务'):
    print(term)

hankcs avatar Sep 08 '18 15:09 hankcs

发现在springboot项目中使用debug as junit时无法运行 @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class HanlpArtAnalysisTest { @Test public void Test() { String str="不及f-22灵活"; // Segment seg=HanLP.newSegment(); System.out.println(NLPTokenizer.segment(str)); System.out.println(HanLP.segment(str)); System.out.println(StandardTokenizer.segment(str));

}

}

testliu123 avatar Sep 11 '18 09:09 testliu123

把@@SpringBootTest去掉,不要用SpringBoot测试,用普通就行了

whaozl avatar Sep 14 '18 11:09 whaozl