当前位置:   article > 正文

中英文分句_sentencesplitter 支持什么语种

sentencesplitter 支持什么语种

中英文分句

这里主要是使用了两个包:pyltp 和 nltk

安装过程省略,使用方式如下:

  1. import nltk # 英文分句
  2. from pyltp import SentenceSplitter # 中文分句
  3. s = "Since I was very small, I was very shy in the public place, so I always avoided giving performance in front of so many people. Though I tried hard to get over it in school, I still felt uneasy in the public place. When I came to the job market, I realized that I must get over my fear, or I would lose my stage.
  4. print "\n".join(nltk.sent_tokenize(s))
  5. # Since I was very small, I was very shy in the public place, so I always avoided giving performance in front of so many people.
  6. # Though I tried hard to get over it in school, I still felt uneasy in the public place.
  7. # When I came to the job market, I realized that I must get over my fear, or I would lose my stage.
  8. x = "在我很小的时候,在公共场合我会感到非常的害羞,所以我总是避免在人多的情况下表演。虽然我在学校努力想要克服这个问题,但在公共场合我还是感到不自在。当我来到就业市场时,我意识到我必须克服我的恐惧了,否则我将失去自己的舞台。"
  9. sents = SentenceSplitter.split(x)
  10. print "\n".join(sents)
  11. # 在我很小的时候,在公共场合我会感到非常的害羞,所以我总是避免在人多的情况下表演。
  12. # 虽然我在学校努力想要克服这个问题,但在公共场合我还是感到不自在。
  13. # 当我来到就业市场时,我意识到我必须克服我的恐惧了,否则我将失去自己的舞台。

http://www.pythontip.com/blog/post/10012/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/543013
推荐阅读
相关标签
  

闽ICP备14008679号