Python自然语言处理第二章 - 获得文本语料与词汇

一,获取文本语料库

1,古腾堡语料库

古腾堡语料库主要存储的是免费的电子图书。

import nltk
from nltk.corpus import *
fileids = gutenberg.fileids();
text1 = gutenberg.words(fileids[0]);
len(text1)

# 如果要使用第一章中的concordance()等函数需要将text1转换为Text类型...
text1_1 = nltk.Text(text1);
text1_1.concordance('surprize');

# 常用操作,raw()函数给我们的是没有进行任何语言学处理的文件的内容
chars = gutenberg.raw(fileids[0]);
words = gutenberg.words(fileids[0]);
sents = gutenberg.sents(fileids[0]);

2,网络与聊天文件

webfiles = webtext.fileids();
chatroom = nps_chat.posts('1--19-20s_706posts.xml');

3,布朗语料库

from nltk.corpus import brown
ctgr = brown.categories();
fileids = brown.fileids();
words1 = brown.words(categories=ctgr[0]);
word2 = brown.words(fileids=fileids[0]);
sents = brown.sents(categories=['news','editorial','reviews']);

4,路透社语料库

5,就职演说语料库

6,标注文本语料库

等等 详见P61

7,文本语料库的结构

PlaintextStructure

8,基本语料库函数

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值