NLTK学习

解决nltk报错:机器学习与NLP实践指南 自然语言处理(Natural Language Processing, NLP)是计算机科学与人工智能领域中研究如何通过算法处理和分析人类语言的一门技术。它能够使计算机理解人类语言的含义,并对语言数据做出智能反应。NLTK(Natural Language Toolkit)是Python编程语言中最流行的自然语言处理库之一,它提供了一系列用于符号和统计自然语言处理的库和程序。NLTK最初由Steven Bird和Edward Loper在宾夕法尼亚大学的计算机与信息科学系开发,并于2001年发布。 阅读详情

nltk: natural language toolkit 是一套基于python的自然语言处理工具集

安装

pip install nltk

在python解释器中

instal nltk
nltk.download()

可以选择下载语料库


Text

一个text里哪些词可以概述这个text的大致内容呢?

1.1搜索

concordance(“word”):显示word出现的上下文,第一次使用可能会比较慢,因为要建立随后的索引,后续索引就会非常快速

from nltk.book import *
text1.concordance('monstrous')

结果:
Displaying 11 of 11 matches:
ong the former , one was of a most monstrous size . … This came towards us ,
ON OF THE PSALMS . ” Touching that monstrous bulk of the whale or ork we have r
ll over with a heathenish array of monstrous clubs and spears . Some were thick
d as you gazed , and wondered what monstrous cannibal and savage could ever hav
that has survived the flood ; most monstrous and most mountainous ! That Himmal
they might scout at Moby Dick as a monstrous fable , or still worse and more de
th of Radney .’” CHAPTER 55 Of the Monstrous Pictures of Whales . I shall ere l
ing Scenes . In connexion with the monstrous pictures of whales , I am strongly
ere to enter upon those still more monstrous stories of them which are to be fo
ght have been rummaged out of this monstrous cabinet there is no telling . But
of Whale - Bones ; for Whales of a monstrous size are oftentimes cast up dead u

similar(‘word’)找出与word相关的单词
common_contexts([“word1”, “word2”])可以找出多个单词相似的上下文,使用逗号分开,包含在方括号中
dispersion_plot([])用离散图判断词在文本的位置即偏移量
这里写图片描述

1.2计数

len(text1)计算长度

print(len(text1))#text1的单词和标点总数 即token数
print(len(set(text1)))#set去掉重复,计数text1中去重后的单词数
print(len(text1[0]))#text1中第一个单词的长度

count(‘word’)单词word在文本中出现了几次

1.3频率

FreqDist()计数每个词出现的次数

fdist1 = FreqDist(text1)
print(fdist1)
print(fdist1.most_common(20))
key = fdist1.keys()
print(list(key)[:5])
ite = fdist1.items()
print(list(ite)[:5])

结果:

[(‘,’, 18713), (‘the’, 13721), (‘.’, 6862), (‘of’, 6536), (‘and’, 6024), (‘a’, 4569), (‘to’, 4542), (‘;’, 4072), (‘in’, 3916), (‘that’, 2982), (“’”, 2684), (‘-‘, 2552), (‘his’, 2459), (‘it’, 2209), (‘I’, 2124), (’s’, 1739), (‘is’, 1695), (‘he’, 1661), (‘with’, 1659), (‘was’, 1632)]
[‘[‘, ‘Moby’, ‘Dick’, ‘by’, ‘Herman’]
[(‘[‘, 3), (‘Moby’, 84), (‘Dick’, 84), (‘by’, 1137), (‘Herman’, 1)]

显示单词的累计频率图:

fdist1.plot(20,cumulative = True)

这里写图片描述

1.4细粒度选词
v = set(text1)
long_words=[w for w in v if len(w)>7]
sorted(long_words)

通常太短的单词不具有代表性,所以选择长度长一些的单词;但是过长的单词很可能是罕见词,所以最好挑选长度够长而且出现频率够大的词

v = set(text1)
fdq = FreqDist(text1)
print(sorted(w for w in v if len(w)>7 and fdq[w]>7))
1.5搭配和双连词

red wine是一个搭配,而the wine就不是
为了找到搭配先用bigrams()找到一组组的单词对儿

print(list(bigrams(['more','is','said','than','done'])))

结果为:
[(‘more’, ‘is’), (‘is’, ‘said’), (‘said’, ‘than’), (‘than’, ‘done’)]
找到频率较高的这样的双连词就可以认为是搭配,词语搭配出现的频率可能比我们期待的单独的单词频率要高,collections()函数就是找搭配的

print(text4.collocations())

结果为:
United States; fellow citizens; four years; years ago; Federal
Government; General Government; American people; Vice President; Old
World; Almighty God; Fellow citizens; Chief Magistrate; Chief Justice;
God bless; every citizen; Indian tribes; public debt; one another;
foreign nations; political parties

1.6 NLTK频率分布中定义的函数

这里写图片描述


Python中字符串的一些常用函数,可能作为筛选条件
这里写图片描述

从仿真到实战:PMOS缓启动与栅极泄放电路的优化设计 本文深入探讨了PMOS缓启动与栅极泄放电路的优化设计,通过立创EDA仿真和实物调试,解决了关断速度慢和耐压问题。文章详细介绍了电路改进方案和低功耗优化技巧,为工程师提供了实用的工程实践建议,帮助提升电源开关电路的性能和可靠性。 阅读详情

相关推荐

麒麟V10系统命令实战指南:从入门到精通

本文为麒麟V10操作系统用户提供了一份从入门到精通的命令行实战指南。内容涵盖文件管理、进程监控、网络诊断、文本处理及系统管理等核心场景,旨在帮助用户转变思维,掌握高效解决实际问题的系统命令技巧,从而提升在麒麟V10环境下的运维与工作效率。

sat99的博客 594

Python自然语言处理:NLTK入门指南

自然语言处理(Natural Language Processing,NLP)是指计算机处理人类语言的领域。它是一门多学科交叉的学科,将计算机科学、人工智能、语言学等诸多学科的理论和方法融合在一起,将人类语言转化为计算机所能理解的形式,实现对人类语言的自动处理、理解和生成。NLP可以应用到很多方面,比如语音识别、机器翻译、情感分析、智能客服等等。NLTK是Natural Language Toolkit的缩写,是Python自然语言处理领域中最流行的一款工具包。

BXA 1万+

Immich vs Nextcloud照片管理实测:自建私有云相册到底选哪个?

本文深度评测了Immich与Nextcloud在私有云相册管理中的表现,涵盖核心功能、性能基准、本土化实践及进阶功能。Immich凭借微服务架构和AI优化在照片管理、移动端体验上表现优异,而Nextcloud则强在生态整合。文章还提供了Docker部署优化和国内网络适配方案,帮助用户根据需求选择最佳方案。

seed的博客 329

自然语言处理库——NLTK

NLTK(www.nltk.org)是在处理预料库、分类文本、分析语言结构等多项操作中最长遇到的包。其收集的大量公开数据集、模型上提供了全面、易用的接口,涵盖了分词、词性标注(Part-Of-Speech tag, POS-tag)、命名实体识别(Named Entity Recognition, NER)、句法分析(Syntactic Parse)等各项 NLP 领域的功能。 ...

满腹的小不甘 7926

用OpenCV+ROS实现焊接机器人智能纠偏:线激光视觉的算法调参全流程

本文详细介绍了基于OpenCV和ROS的焊接机器人智能纠偏系统全流程。通过线激光视觉系统实时感知焊缝,重点解析了抗干扰图像预处理、改进的Steger算法提取激光条纹中心线,以及从2D像素到机器人基坐标系的完整坐标变换。该系统为应对焊接飞溅、弧光等复杂工况,实现高精度实时路径纠偏提供了从算法优化到工程集成的完整解决方案。

vodka的博客 159

【LE Audio】CAP精讲[1]: 从理论到实操,CAP 协同流程入门全攻略

LEAudio生态中的CommonAudioProfile(CAP)是一个关键协同框架,它通过整合基础音频协议(BAP/VCP/MICP等)构建多设备协同能力。CAP定义了三大核心功能:音频流管理、设备组控制和统一交互服务,解决了传统蓝牙音频在多设备场景下的协同痛点。其规范历经v1.0到v1.0.1的优化,修正了角色定义、连接流程等关键模块,提升设备兼容性。CAP采用严格的语言约定(shall/must/should)和术语体系(ContextType/CCID/协同集),确保不同厂商设备能相互理解。

byte轻骑兵的技术小窝 2万+

【小沐学NLP】Python使用NLTK库的入门教程

NLTK - 自然语言工具包 - 是一套开源Python。支持自然研究和开发的模块、数据集和教程 语言处理。NLTK 需要 Python 版本 3.7、3.8、3.9、3.10 或 3.11。NLTK是一个高效的Python构建的平台,用来处理人类自然语言数据。它提供了易于使用的接口,通过这些接口可以访问超过50个语料库和词汇资源(如WordNet),还有一套用于分类、标记化、词干标记、解析和语义推理的文本处理库,以及工业级NLP库的封装器和一个活跃的讨论论坛。

爱看书的小沐 1万+

开关电源和线性电源Multisim电路仿真实验汇总——硬件工程师笔记

本文系统介绍了稳压电源的基础知识与应用实验。首先阐述了稳压电源的定义与类型,包括线性稳压电源(如LM7805/7905)和开关稳压电源(降压/升压/升降压式)的工作原理、参数特点及优劣势。随后详细讲解了各类稳压电源的实验设计,如线性稳压电源的电路实现、开关稳压电源的PWM控制方法等。最后汇总了硬件工程师相关的笔试面试资源,涵盖器件知识、电路仿真、企业真题等内容。全文结合理论分析与Multisim仿真,为电子工程学习者提供了稳压电源的实用技术参考。

XU157303764的博客 1640

NLTK 基础知识总结

什么事实NLTK NLTK,全称Natural Language Toolkit,自然语言处理工具包,是NLP研究领域常用的一个Python库,由宾夕法尼亚大学的Steven Bird和Edward Loper在Python的基础上开发的一个模块,至今已有超过十万行的代码。这是一个开源项目,包含数据集、Python模块、教程等; 怎样安装 详情可以参见我的另一篇博客NLP的开发环境搭建,通...

村雨遥 2万+

AUTOSAR MCAL开发及EB Tresos工具使用总结

在基于AutoSar CP架构开发MCAL时,会使用到EB tresos工具。本文主要对MCAL开发及EB tresos工具使用进行总结,仅作为自学使用,以方便后续查漏补缺。

liuxu324的博客 2626

PCL学习笔记(四)——点云曲面重建

文章目录一、凸包算法二、 单纯的点云数据固然很好,但仅仅是点的话仍是不够的,因为这不利于我们后续对实体对象的渲染与各种应用,如计算实体的表面积、体积等等,所以这就需要我们对实体进行点云的曲面重建。 一、凸包算法 在计算机图形学中,凸包是指在任意维空间中包含某一有限点集P的最小凸集,它由凸包顶点构成,在二维上其表现形式为一个凸多边形,而在三维上则表现为一个凸多面体。在二维层面上来讲,最常用的凸包算法有Graham扫描法和Jarvis卷包裹法,但前者并不适用于三维层面,后者倒是可以扩展到三维。除此之外,在

dayuhaitang1的博客 6912

NLTK库安装教程(详细版)

nltk库 安装教程

weixin_51327281的博客 5万+

C#与天文观测:Celestia模拟星空的奇幻之旅

Celestia就像一艘穿梭在星海中的小飞船,带领我们遨游宇宙。C#则是这艘飞船的智能导航系统,用代码指挥它飞向任何我们向往的星球或星系。首先,下载并安装Celestia,熟悉其基本操作和功能。创建一个星空目标列表,包括不同的恒星、行星和星系。// 示例:定义观察目标列表new SpaceObject("太阳"),new SpaceObject("月球"),new SpaceObject("火星")

java专栏 1456

NLTK学习笔记——开篇

本人试过阅读书籍并在书上做笔记,奈何脑容量不足,书上的笔记也是杂乱无章,发现读过之处就好像没读。于是决定开始写NLTK系列的读书笔记。 本学习笔记主要用于个人备忘之用,会有诸多内容摘自其他网页或文章,本人会尽量写明出处,如有雷同,还请谅解。 本系列的NLTK学习笔记会尽量根据官方文档所标注的12个模块来记录,顺序不完全按照图示顺序,会根据自身的学习情况来定。

cangqiong112758的博客 553

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

python的nltk能做啥_Python NLTK学习2(FreqDist对象)

Python NLTK学习2(FreqDist对象)发表于:2016年12月20日阅读:20007除特别注明外,本站所有文章均为小杰Code原创本系列博客为学习《用Python进行自然语言处理》一书的学习笔记。频率分布打开Python解释器,输入如下代码:import nltkfrom nltk.book import *fdist1 = FreqDist(text1)我们使用Text的实...

weixin_39830323的博客 584

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

NLTK与深度学习的自然语言处理实战:利用NLTK和深度学习构建自定义语言模型

课程摘要 本课程深入讲解NLTK库在语言模型构建中的应用,重点涵盖以下内容: 语言模型基础:介绍统计模型和神经网络模型的差异 文本预处理技术:包括文本清洗、分词和停用词处理 自定义语言模型构建:详细讲解使用PyTorch构建LSTM模型的过程 模型训练方法:涉及数据准备、模型参数设置和训练流程 课程通过代码示例演示了从文本预处理到模型训练的全过程,特别关注如何利用NLTK与深度学习框架结合构建高效的语言模型。

WSSWWWSSW的博客 952

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

NLTK学习笔记——Classify模块(2)

注:本文为实战过程作铺垫,因为参考原文是英文的,每看一遍都要琢磨一遍单词和语法,因此总结一下原文的过程,以备忘之用。本文主要介绍原文中利用NLTK进行twitter语句分类的过程,在下一节就记录本人的实战过程。 参考:http://www.cnblogs.com/wentingtu/archive/2012/04/07/2436583.html 首先与NLTK的例子(即通过name判断gend

cangqiong112758的博客 2865

python的nltk能做啥_Python NLTK学习4(条件频率分布)

Python NLTK学习4(条件频率分布)发表于:2016年12月26日阅读:10703除特别注明外,本站所有文章均为小杰Code原创本系列博客为学习《用Python进行自然语言处理》一书的学习笔记。前文复习前面的博客中我们学习了一些语料库,我们知道布朗语料库是一个按照文体分类的语料库。我们还学习频率分布对象FreqDist。我们指定单词列表变量mylist,FreqDist(mylis...

weixin_39717692的博客 202

(1 NLTK学习笔记

NLTK学习笔记 (1 NLTK学习笔记 1 布朗语料库 导入: Import nltk From nltk.corpus import brown 调用语料库中所有的类别: Print(brown.categories()) 在所有的类别中挑选出某几种类别: Genres=[‘’] Whwords=[‘’] 使用for循环来进行迭代并优化代码行数: for I in range(0,len...

chujiu0的博客 225

Python NLTK的学习(一)

学习目标:搞定nltk 学习内容: 第一章 1.1-1.5 学习时间: 1.2020/10/16 学习产出: >>> from nltk.book import * *** Introductory Examples for the NLTK Book *** Loading text1, ..., text9 and sent1, ..., sent9 Type the name of the text or sentence to view it. Type: 'text

qq_44418077的博客 1911

收纳一些学习nltk过程中遇到的问题

收纳一些学习nltk过程中遇到的问题 python3使用nltk.download()时出错的解决办法 / 离线安装nltk_data

makesomethings的博客 201

NLTK学习总结

2.6 词形还原 lemmatization 词形还原操作会利用上下文语境和词性来确定相关单词的变化形式,并运用不同的标准化规则,根据词性来获取相关的词根(也叫lemma)。 # 词形还原 lemmatization print(nltk.stem.WordNetLemmatizer().lemmatize("ate")) # eat WordNetLemmatizer 使用了wordn...

yegan9112的博客 1090

nltk学习

先pip安装 pip install nltk 然后下载相关语料库: import nltk nltk.download() 检查语料库是否下载完成: from nltk.book import * 句子 -> 从句 -> 短语 -> 单词 词:一门独立语言中的最小单位。 词素:具有独特意义的最小语言单位,但它不是独立的,一个单词可以由...

szuhuanggang的博客 221

nltk学习之统计词频和分词nltk.word_tokenize nltk.FreqDist

分词 (1)可以使用split()函数 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 thei...

机器学习初学者必看,关注我,一起了解机器学习 3369

nltk入门学习记录

NLP(自然语言处理)就是开发能理解人类语言的应用程序和服务。 NLP库,现有许多开源的自然语言处理(NLP)库: Natural language toolkit(NLTK) Apache OpenNLP Stanford NLP suite Gate NLP library 自然语言工具包(NLTK)是最受欢迎的自然语言处理(NLP)库,它是用python语言编写的,背后有强大的社...

qq_43242266的博客 385

NLTK学习一

NLTK

追智的专栏 693
上一篇: Python nltk Learning to classify texts
下一篇: Leetcode 3-最长无重复子串
BeforeEasy
博客等级 码龄10年 92粉丝 207原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值