python分词操作(Python英文文本分词无空格模块wordninja的使用实例)
python分词操作
Python英文文本分词无空格模块wordninja的使用实例在NLP中,数据清洗与分词往往是很多工作开始的第一步,大多数工作中只有中文语料数据需要进行分词,现有的分词工具也已经有了很多了,这里就不再多介绍了。英文语料由于其本身存在空格符所以无需跟中文语料同样处理,如果英文数据中没有了空格,那么应该怎么处理呢?
今天介绍一个工具就是专门针对上述这种情况进行处理的,这个工具叫做:wordninja,地址在这里。
下面简单以实例看一下它的功能:
|
def wordinjaFunc(): ''' https://github.com/yishuihanhan/wordninja ''' import wordninja print wordninja.split( 'derekanderson' ) print wordninja.split( 'imateapot' ) print wordninja.split( 'wethepeopleoftheunitedstatesinordertoformamoreperfectunionestablishjusticeinsuredomestictranquilityprovideforthecommondefencepromotethegeneralwelfareandsecuretheblessingsoflibertytoourselvesandourposteritydoordainandestablishthisconstitutionfortheunitedstatesofamerica' ) print wordninja.split( 'littlelittlestar' ) |
结果如下:
['derek', 'anderson']
['im', 'a', 'teapot']
['we', 'the', 'people', 'of', 'the', 'united', 'states', 'in', 'order', 'to', 'form', 'a', 'more', 'perfect', 'union', 'establish', 'justice', 'in', 'sure', 'domestic', 'tranquility', 'provide', 'for', 'the', 'common', 'defence', 'promote', 'the', 'general', 'welfare', 'and', 'secure', 'the', 'blessings', 'of', 'liberty', 'to', 'ourselves', 'and', 'our', 'posterity', 'do', 'ordain', 'and', 'establish', 'this', 'constitution', 'for', 'the', 'united', 'states', 'of', 'america']
['little', 'little', 'star']
从简单的结果上来看,效果还是不错的,之后在实际的使用中会继续评估。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对开心学习网的支持。如果你想了解更多相关内容请查看下面相关链接
原文链接:https://blog.csdn.net/Together_CZ/article/details/86678213
- python 获取ip mac 地址(Python3获取电脑IP、主机名、Mac地址的方法示例)
- python 读文件报错处理(解决python写入带有中文的字符到文件错误的问题)
- pythondjango搭建web(PythonWeb项目Django部署在Ubuntu18.04腾讯云主机上)
- python中list用法(Python数据类型之List列表实例详解)
- python什么是深拷贝什么是浅拷贝(Python深拷贝与浅拷贝用法实例分析)
- python操作pandas(详解Python学习之安装pandas)
- python入门之字符串处理(Python中常用的8种字符串操作方法)
- python下划线怎么用(Python3中_下划线和__双下划线的用途和区别)
- opencv提取图像轮廓python代码(Python基于opencv调用摄像头获取个人图片的实现方法)
- python编程ai人工智能(AI领域都在用Python即将被淘汰?网友预测未来的编程语言不会是TA)
- python小程序编程代码(python实现烟花小程序)
- pythonqt入门教程(使用python实现mqtt的发布和订阅)
- python支持面向对象的程序设计(Python面向对象程序设计之类的定义与继承简单示例)
- 零基础学计算机二级python(计算机二级python学习教程1 教大家如何学习python)
- 如何查看python beautifulsoup(Python爬虫beautifulsoup4常用的解析方法总结)
- python创建进程的方法(Python多进程fork函数详解)
- 网红直播可以赚很多钱吗(网红直播可以赚很多钱吗)
- 今天是什么日子(今天是什么日子有什么特殊意义吗)
- 这里输入关键词(怎么输入关键词搜索)
- 34岁的舒畅,就这样走到了末路,不知会不会后悔15年前的草率决定(就这样走到了末路)
- 不走心的古装造型 舒畅 毁容式 出演,萧蔷雷出新高度(不走心的古装造型)
- 嘉南传 第22集(嘉南传第22集)
热门推荐
- css文本怎么控制边距(css中text-overflow属性与文本截断详解)
- docker容器映射到宿主机器(在宿主机上执行docker容器内部的shell或程序方式)
- docker启动指定容器ip(Docker每次启动容器,IP及hosts指定的操作)
- asp.net去除字符串中html标签
- django中filter的参数(详解django2中关于时间处理策略)
- mysql 查询出来的字段拼接(mysql 多个字段拼接的实例详解)
- dedecms编写模板(dedecms模板怎么修改)
- css行高line-height的用法
- html5 canvas touch(html5 canvas手势解锁源码分享)
- python实现在同一电脑上tcp通信(Python两台电脑实现TCP通信的方法示例)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9