自然语言25_nltk.book

测试NLTK数据包
导入nltk.book包中所有的东西:

能使用以下函数的是nltk.text.Text对象

 from nltk.book import *

 

 

text1.concordance("monstrous")

找出文中含有单词monstrous的语句

 

再看几个例子。
查看语料库中的文本信息,直接敲它的名字:

 
    1. >>> text1  
    2. <Text: Moby Dick by Herman Melville 1851>

 

 

text1.similar('monstrous')

找出文中与单词monstrous(畸形,丑陋)的同义词

 

查看词语的分散度图

text4.dispersion_plot(['citizens','democracy','freedom','duties','America'])  

 

 

https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149(博主视频教学主页)

原文地址:https://www.cnblogs.com/webRobot/p/6103683.html