nltk 中的 sents 和 words ,为后续处理做准备。

#!/usr/bin/env python
# -*- coding: utf-8 -*-from nltk.corpus import gutenberg
sents = gutenberg.sents("burgess-busterbrown.txt")
print(sents[1:20])words = gutenberg.words("burgess-busterbrown.txt")
print(words[1:20])

输出:

[['I'], ['BUSTER', 'BEAR', 'GOES', 'FISHING'], ['Buster', 'Bear', 'yawned', 'as', 'he', 'lay', 'on', 'his', 'comfortable', 'bed', 'of', 'leaves', 'and', 'watched', 'the', 'first', 'early', 'morning', 'sunbeams', 'creeping', 'through', 'the', 'Green', 'Forest', 'to', 'chase', 'out', 'the', 'Black', 'Shadows', '.'], ['Once', 'more', 'he', 'yawned', ',', 'and', 'slowly', 'got', 'to', 'his', 'feet', 'and', 'shook', 'himself', '.'], ['Then', 'he', 'walked', 'over', 'to', 'a', 'big', 'pine', '-', 'tree', ',', 'stood', 'up', 'on', 'his', 'hind', 'legs', ',', 'reached', 'as', 'high', 'up', 'on', 'the', 'trunk', 'of', 'the', 'tree', 'as', 'he', 'could', ',', 'and', 'scratched', 'the', 'bark', 'with', 'his', 'great', 'claws', '.'], ['After', 'that', 'he', 'yawned', 'until', 'it', 'seemed', 'as', 'if', 'his', 'jaws', 'would', 'crack', ',', 'and', 'then', 'sat', 'down', 'to', 'think', 'what', 'he', 'wanted', 'for', 'breakfast', '.'], ['While', 'he', 'sat', 'there', ',', 'trying', 'to', 'make', 'up', 'his', 'mind', 'what', 'would', 'taste', 'best', ',', 'he', 'was', 'listening', 'to', 'the', 'sounds', 'that', 'told', 'of', 'the', 'waking', 'of', 'all', 'the', 'little', 'people', 'who', 'live', 'in', 'the', 'Green', 'Forest', '.'], ['He', 'heard', 'Sammy', 'Jay', 'way', 'off', 'in', 'the', 'distance', 'screaming', ',', '"', 'Thief', '!'], ['Thief', '!"'], ['and', 'grinned', '.'], ['"', 'I', 'wonder', ',"', 'thought', 'Buster', ',', '"', 'if', 'some', 'one', 'has', 'stolen', 'Sammy', "'", 's', 'breakfast', ',', 'or', 'if', 'he', 'has', 'stolen', 'the', 'breakfast', 'of', 'some', 'one', 'else', '.'], ['Probably', 'he', 'is', 'the', 'thief', 'himself', '."'], ['He', 'heard', 'Chatterer', 'the', 'Red', 'Squirrel', 'scolding', 'as', 'fast', 'as', 'he', 'could', 'make', 'his', 'tongue', 'go', 'and', 'working', 'himself', 'into', 'a', 'terrible', 'rage', '.'], ['"', 'Must', 'be', 'that', 'Chatterer', 'got', 'out', 'of', 'bed', 'the', 'wrong', 'way', 'this', 'morning', ',"', 'thought', 'he', '.'], ['He', 'heard', 'Blacky', 'the', 'Crow', 'cawing', 'at', 'the', 'top', 'of', 'his', 'lungs', ',', 'and', 'he', 'knew', 'by', 'the', 'sound', 'that', 'Blacky', 'was', 'getting', 'into', 'mischief', 'of', 'some', 'kind', '.'], ['He', 'heard', 'the', 'sweet', 'voices', 'of', 'happy', 'little', 'singers', ',', 'and', 'they', 'were', 'good', 'to', 'hear', '.'], ['But', 'most', 'of', 'all', 'he', 'listened', 'to', 'a', 'merry', ',', 'low', ',', 'silvery', 'laugh', 'that', 'never', 'stopped', 'but', 'went', 'on', 'and', 'on', ',', 'until', 'he', 'just', 'felt', 'as', 'if', 'he', 'must', 'laugh', 'too', '.'], ['It', 'was', 'the', 'voice', 'of', 'the', 'Laughing', 'Brook', '.'], ['And', 'as', 'Buster', 'listened', 'it', 'suddenly', 'came', 'to', 'him', 'just', 'what', 'he', 'wanted', 'for', 'breakfast', '.']]
['The', 'Adventures', 'of', 'Buster', 'Bear', 'by', 'Thornton', 'W', '.', 'Burgess', '1920', ']', 'I', 'BUSTER', 'BEAR', 'GOES', 'FISHING', 'Buster', 'Bear']Process finished with exit code 0

nltk 中的 sents 和 words相关推荐

  1. python语法详解_关于python:NLTK中解析的英语语法

    是否有可以立即使用并可以在NLTK中使用的即用型英语语法? 我搜索了使用NLTK进行解析的示例,但似乎我必须在解析句子之前手动指定语法. 非常感谢! 您可以看一下pyStatParser,这是一个简单 ...

  2. r与python自然语言处理_Python自然语言处理实践: 在NLTK中使用斯坦福中文分词器 | 我爱自然语言处理...

    斯坦福大学自然语言处理组是世界知名的NLP研究小组,他们提供了一系列开源的Java文本分析工具,包括分词器(Word Segmenter),词性标注工具(Part-Of-Speech Tagger), ...

  3. python中pos是什么_如何在NLTK中使用pos_标记?

    所以我试着在列表中标记一堆单词(确切地说是POS标记)如下:pos = [nltk.pos_tag(i,tagset='universal') for i in lw] 其中lw是一个单词列表(它确实 ...

  4. 关于NLTK中tokenizers的问题

    最近在使用nlkt库进行分词任务和词性还原任务时遇到了一些问题,在这里做一些记录 解决办法 尝试使用图中所给的: import nltk nltk.download 这种方法在我这里不行,报错如下 转 ...

  5. NLP之路-实验nltk中的raw 和 words

     为了实验首先在nltk_data中建立了一个实验文本文件,如下: 文字内容是: hello this is a test sentence. this is the second line ha ...

  6. 中文停用词文档_使用Python中的NLTK和spaCy删除停用词与文本标准化

    译者 | VK 来源 | Analytics Vidhya [磐创AI 导读]:本文介绍了如何使用Python中的NLTK和spaCy删除停用词与文本标准化,欢迎大家转发.留言.想要更多电子杂志的机器 ...

  7. python自然语言分析 何翠仪_如何用 Python 中的 NLTK 对中文进行分析和处理?

    最近正在用nltk 对中文网络商品评论进行褒贬情感分类,计算评论的信息熵(entropy).互信息(point mutual information)和困惑值(perplexity)等(不过这些概念我 ...

  8. [转载] 使用Python中的NLTK和spaCy删除停用词与文本标准化

    参考链接: Python | 用NLTK进行词干分析 概述 了解如何在Python中删除停用词与文本标准化,这些是自然语言处理的基本技术  探索不同的方法来删除停用词,以及讨论文本标准化技术,如词干化 ...

  9. nltk词性标注与词形还原中的词性类型匹配

    一.两函数词性不匹配问题: nltk中词性标注函数nltk.pos_tag([])得到的结果:NN,NNP,VB等 nltk中词形还原函数nltk.stem.WordNetLemmatizer().l ...

最新文章

  1. C指针9:指针数组(即数组中的每个元素都是指针)
  2. php 换台电脑 表单部分_PHP更新购物车数量(表单部分/PHP处理部分)
  3. 添加firefox4的deb源,直接安装
  4. 技术人员如何创业《四》- 打造超强执行力团队
  5. 在linux下Qt使用sqlite,QT中SQLite使用【实例】
  6. view函数_数据科学系列:数据处理(6)字符串函数基于R(二)
  7. 客户关系管理SAP整体解决方案
  8. 计算机在智能交通应用,计算机技术在智能交通系统的应用
  9. 评论:IBM大型机能靠云计算挽回颓势吗?
  10. 【搞事情】英文文档单词对比自动翻译
  11. VS2012无法打开文件“kernel32.lib”问题的解决办法
  12. Java期末考试知识点复习
  13. vue省市区三级联动(地区编码)
  14. 在外行人眼里程序员是一个怎样的群体?
  15. PyQt5 文件保存对话框
  16. blender 鼠标滑轮配合快捷键
  17. python语言发展历史
  18. LoRaWAN协议-物理层(PHY)详解
  19. URL 的参数(query)是什么,以及如何解析获取
  20. 解决chorm火狐浏览器被hao123和2345主页劫持问题(亲测有效)

热门文章

  1. Python继承范例
  2. linux压缩命令gzip_Linux gzip命令示例
  3. linux信号(二)--unix环境高级编程读书笔记
  4. 开课吧:全栈工程师的关键开发技能(硬实力)
  5. 开课吧课堂:C++基本数据类型详解
  6. Java编译期优化思维导图
  7. React Native三端融合在沪江的应用实践
  8. PXE 自动安装物理机 (DHCP服务由路由提供, 不能再配置)
  9. 必须拉响恶性通胀的警报
  10. Java开发设计——UML类图