NLP整体流程的代码
import nltk
import numpy as np
import re
from nltk.corpus import stopwords # 1 分词1
text = "Sentiment analysis is a challenging subject in machine learning.\
People express their emotions in language that is often obscured by sarcasm,\
ambiguity, and plays on words, all of which could be very misleading for \
both humans and computers. There's another Kaggle competition for movie review \
sentiment analysis. In this tutorial we explore how Word2Vec can be applied to \
a similar problem.".lower() text_list = nltk.word_tokenize(text) #2 q去掉标点符号和停用词
#去掉标点符号
english_punctuations = [',', '.', ':', ';', '?', '(', ')', '[', ']', '&', '!', '*', '@', '#', '$', '%']
text_list = [word for word in text_list if word not in english_punctuations]
#去掉停用词
stops = set(stopwords.words("english"))
text_list = [word for word in text_list if word not in stops] #3统计词频
freq_dist = nltk.FreqDist(text_list)
freq_list = []
num_words = len(freq_dist.values())
for i in range(num_words):
freq_list.append([list(freq_dist.keys())[i],list(freq_dist.values())[i]])
freqArr = np.array(freq_list)
print(freqArr) #4词性标注
print(nltk.pos_tag(text_list))
NLP整体流程的代码的更多相关文章
- 使用git整体流程
一.git提交代码走meger请求的整体流程 工作中使用git推代码时,如果走merge请求,那么也就是说拉代码时拉公共代码库的代码,但是提交时需要先提交到自己的代码库,然后在gitlab上提交mer ...
- Mybatis技术原理理——整体流程理解
前言:2018年,是最杂乱的一年!所以你看我的博客,是不是很空! 网上有很多关于Mybatis原理介绍的博文,这里介绍两篇我个人很推荐的博文 Mybatis3.4.x技术内幕和 MyBaits源码分析 ...
- [uboot] (第三章)uboot流程——uboot-spl代码流程
http://blog.csdn.net/ooonebook/article/details/52957395 以下例子都以project X项目tiny210(s5pv210平台,armv7架构)为 ...
- 【驱动】input子系统整体流程全面分析(触摸屏驱动为例)【转】
转自:http://www.cnblogs.com/lcw/p/3294356.html input输入子系统整体流程 input子系统在内核中的实现,包括输入子系统(Input Core),事件处理 ...
- linux input输入子系统分析《四》:input子系统整体流程全面分析
1 input输入子系统整体流程 本节分析input子系统在内核中的实现,包括输入子系统(Input Core),事件处理层(Event Handler)和设备驱动层.由于上节代码讲解了设备 ...
- (转)linux内存源码分析 - 内存回收(整体流程)
http://www.cnblogs.com/tolimit/p/5435068.html------------linux内存源码分析 - 内存回收(整体流程) 概述 当linux系统内存压力就大时 ...
- HDFS源码分析DataXceiver之整体流程
在<HDFS源码分析之DataXceiverServer>一文中,我们了解到在DataNode中,有一个后台工作的线程DataXceiverServer.它被用于接收来自客户端或其他数据节 ...
- Okhttp3源码解析(3)-Call分析(整体流程)
### 前言 前面我们讲了 [Okhttp的基本用法](https://www.jianshu.com/p/8e404d9c160f) [Okhttp3源码解析(1)-OkHttpClient分析]( ...
- 64位CreateProcess逆向:(二)0环下参数的整合即创建进程的整体流程
转载:https://bbs.pediy.com/thread-207683.htm 点击下面进入总目录: 64位Windows创建64位进程逆向分析(总目录) 在上一篇文章中,我们介绍了Create ...
随机推荐
- python中模块的引用
一. 模块的定义 定义 python模块(Module),是一个python文件,以.py结尾,包含了python对象定义和python语句.模块让你能够有逻辑地组织你的python代码段,把相关的代 ...
- Java面试题下
这部分主要是开源Java EE框架方面的内容,包括hibernate.MyBatis.spring.Spring MVC等,由于Struts 2已经是明日黄花,在这里就不讨论Struts 2的面试题, ...
- Hash Join 一定是选择小表作为驱动表吗
原来自己也是一直认为oralce会选择小表作为驱动表,以前一直也没注意,今天看了落落大神的实验,才发现,oralce查询时不一定选择小表作为驱动表. 如果对大表增加了约束,大表也会作为驱动表. 实验见 ...
- js动态拼接参数到请求的url上
var queryConfig={ "page" : "index", "method" : 2, //1:按照方法A查看 2:按照方法B查 ...
- 从jQuery学细节
前言 最近看了两遍jQuery源码,感觉只是看懂了jQuery的小部分小部分,不过仅此,就已经对john resig佩服的五体投地咯.. 下面附上这位帅哥的靓照,记住吧,是他改变了世界. 看的大多是实 ...
- FMDB的操作(转),这篇比我写的好
直接看吧 http://blog.devtang.com/blog/2012/04/22/use-fmdb/
- 树莓派(Arduino)仿真软件 —— Fritzing
Fritzing 官网:Fritzing Fritzing 下载地址:Fritzing Download windows 下降 zip 文件解压后,免安装双击 exe 即可运行:
- weinre
https://www.cnblogs.com/diva/p/3995674.html
- CodeForces - 794C:Naming Company(博弈&简单贪心)
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little thi ...
- 《Javascript高级程序设计》阅读记录(三):第五章 上
这个系列以往文字地址: <Javascript高级程序设计>阅读记录(一):第二.三章 <Javascript高级程序设计>阅读记录(二):第四章 这个系列,我会把阅读< ...