nltk 中的 sents 和 words
来源:互联网 发布:淘宝网红直播推广费用 编辑:程序博客网 时间:2024/06/06 03:09
nltk 中的 sents 和 words ,为后续处理做准备。
#!/usr/bin/env python# -*- coding: utf-8 -*-from nltk.corpus import gutenbergsents = 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
阅读全文
0 0
- nltk 中的 sents 和 words
- NLP之路-实验nltk中的raw 和 words
- 用python中的nltk进行分析和处理
- nltk在python中的安装,以及nltk的data库
- NLTK
- nltk
- 安装和使用NLTK分词和去停词
- 安装和使用NLTK分词和去停词
- 探索 Python、机器学习和 NLTK 库
- Python 2.7和NLTK安装教程
- 探索 Python、机器学习和 NLTK 库
- nltk对中文进行处理和分析
- Python 2.7和NLTK安装教程
- 5.NLTK之分类和标注词汇
- 在Windows上安装python和NLTK
- NLTK进行英文分句和分词
- nltk.获得文本语料和词汇资源
- [python+nltk] 自然语言处理简单介绍和NLTK坏境配置及入门知识(一)
- Java学习第十四天
- git 创建/删除本地/远程分支
- Springboot-系统异常统一处理(接口编程异常处理)
- 常用类的对比
- 【项目搭建】使用spring-boot进行REST风格的微服务开发入门
- nltk 中的 sents 和 words
- 5.jfinal上传下载文件
- leetcode 340. Longest Substring with At Most K Distinct Characters
- Java NIO Pipe使用示例
- Java集合分类以及各自特点
- jdk 源码分析(2)java hashtable的结构及hashMap对比
- 查看本机ssh公钥,生成公钥
- Redis学习——01.redis安装
- 链表操作(链表面试题)