1、知识点

包括中文和英文的词性标注
主要使用的库是nltk和jiaba

2、代码

# coding = utf-8

import nltk
from nltk.corpus import stopwords
from nltk.corpus import brown
import numpy as np
"""
标注步骤:
1、清洗,分词
2、标注 FAQ:
1、 Resource punkt not found.
请安装punkt模块
2、安装average_perceptron tagger
3、Resource sinica_treebank not found
请安装sinica_treebank模块
"""
def english_label():
"""
英文词性标注
:return:
"""
# 分词
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.".lower()
text_list = nltk.word_tokenize(text)
# 去掉标点符号
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] list = nltk.pos_tag(text_list) #打标签
print(list) def chineses_label():
import jieba.posseg as pseg
import re
"""
fool也可以针对中文词性标注
HanLP词性标注集
案例使用jieba进行词性标注
:return:
"""
str = "我爱你,是粉色,舒服 ,舒服,士大夫"
posseg_list = re.sub(r'[,]', " ", str)
posseg_list =pseg.cut(posseg_list)
print(posseg_list)
print(' '.join('%s/%s' % (word, tag) for (word, tag) in posseg_list))

python之NLP词性标注的更多相关文章

  1. nlp词性标注

    nlp词性标注 与分词函数不同,jieba库和pyltp库词性标注函数上形式相差极大. jieba的词性标注函数与分词函数相近,jieba.posseg.cut(sentence,HMM=True)函 ...

  2. Viterbi 算法 Python实现 [NLP学习一]

    最近思考了一下未来,结合老师的意见,还是决定挑一个方向开始研究了,虽然个人更喜欢鼓捣.深思熟虑后,结合自己的兴趣点,选择了NLP方向,感觉比纯粹的人工智能.大数据之类的方向有趣多了,个人还是不适合纯粹 ...

  3. python之NLP数据清洗

    1.知识点 """ 安装模块:bs4 nltk gensim nltk:处理英文 1.安装 2.nltk.download() 下载相应的模块 英文数据处理: 1.去掉h ...

  4. Python 基于 NLP 的文本分类

    这是前一段时间在做的事情,有些python库需要python3.5以上,所以mac请先升级 brew安装以下就好,然后Preference(comm+',')->Project: Text-Cl ...

  5. NLP入门(二)探究TF-IDF的原理

    TF-IDF介绍   TF-IDF是NLP中一种常用的统计方法,用以评估一个字词对于一个文件集或一个语料库中的其中一份文件的重要程度,通常用于提取文本的特征,即关键词.字词的重要性随着它在文件中出现的 ...

  6. NLP入门(十)使用LSTM进行文本情感分析

    情感分析简介   文本情感分析(Sentiment Analysis)是自然语言处理(NLP)方法中常见的应用,也是一个有趣的基本任务,尤其是以提炼文本情绪内容为目的的分类.它是对带有情感色彩的主观性 ...

  7. 【448】NLP, NER, PoS

    目录: 停用词 —— stopwords 介词 —— prepositions —— part of speech Named Entity Recognition (NER) 3.1 Stanfor ...

  8. Mac os Pycharm 中使用Stanza进行实体识别(自然语言处理nlp)

    stanza 是斯坦福开源Python版nlp库,对自然语言处理有好大的提升,具体好在哪里,官网里面都有介绍,这里就不翻译了.下面放上对应的官网和仓库地址. stanza 官网地址:点击我进入 sta ...

  9. 【NLP】干货!Python NLTK结合stanford NLP工具包进行文本处理

    干货!详述Python NLTK下如何使用stanford NLP工具包 作者:白宁超 2016年11月6日19:28:43 摘要:NLTK是由宾夕法尼亚大学计算机和信息科学使用python语言实现的 ...

随机推荐

  1. Windows7用VirtualBox虚拟Ubuntu共享文件夹的终极方式

    在Win7用VirtualBox虚拟机安装Ubuntu后,共享文件夹再也不用手工mount了 安装增强工具包 设置共享文件夹后 VB已经自动挂载Windows文件夹到 /media/sf_*** 目录 ...

  2. Winform 多项目共用AssemblyInfo解决方案

    Winform 多项目共用AssemblyInfo解决方案: 操作步骤如下: 第一步:复制任何项目中的AssemblyInfo.cs文件至指定目录 第二步:删除所有项目的AssemblyInfo.cs ...

  3. 【完美解决】vue,页面跳转样式错位但是刷新又好了的情况

    在vue文件中,做样式分离: 将覆盖样式单独写在一个style标签内,原页面写在 scoped样式作用域下.

  4. 4.caffe:train_val.prototxt、 solver.prototxt 、 deploy.prototxt( 创建模型与编写配置文件)

    一,train_val.prototxt name: "CIFAR10_quick" layer { name: "cifar" type: "Dat ...

  5. ext系统的超级块

    什么是超级块 如果说inode块是Linux操作系统中文件的核心,那么超级块就是文件系统的心脏.启动Lnux操作系统后,发现某个文件系统无法使用,很有 可能就是超级块出现了问题.为什么这个超级块有这么 ...

  6. 基于蓝图的完整的Flask项目

    其一Flask_Script 安装: pip3 install flask_script flask_script作用: -改变flask的启动方式:python manage.py runserve ...

  7. [Svelte 3] Use an onMount lifecycle method to fetch and render data in Svelte 3

    Every Svelte component has a lifecycle that starts when it is created, and ends when it is destroyed ...

  8. 获取节点 document.getElementBy{Id,Name,TagName,ClassName

    document.getElementById(" "); document.getElementByName(" "); document.getElemen ...

  9. 【Android-自定义控件】SwipeRefreshDemo 下拉刷新,上拉加载

    参考:https://github.com/PingerOne/SwipeRefreshDemo 谷歌官方的SwipeRefreshLayout控件,只有下拉刷新功能. 自定义的SwipeRefres ...

  10. 在gitlab上删除分支后,本地git branch -r还能看到

    1. git remote prune --dry-run origin 查看当前有哪些是该消失还存在的分支 2. git remote prune origin 删除上面展示的所有分支 3. git ...