NLTK之搜索文本的相关入门函数(一)
2017-03-19 19:58
375 查看
·搜索文本用到的相关函数
1.concordance() 函数;利用函数concordance可以显示指定单词在文本中出现情况,并显示上下文。
如下例中,查找单词monstrous
2.similar()函数; 可以用来查找与指定单词意义,用法相似的词,可以可以用在搜索引擎中的相关度识别功能中
3.common_contexts()函数 ;可以用来研究共用两个或两个以上词汇的上下文
4.generate()函数;用于随机生成文本
注:本文中所有代码均来自《Python自然语言处理》(Steven bird,Ewan Klein&Edward Loper)
1.concordance() 函数;利用函数concordance可以显示指定单词在文本中出现情况,并显示上下文。
如下例中,查找单词monstrous
>>>from nltk.book import*
....
>>>text1.concordance("monstrous") Building index... Displaying 11 of 11matches:ong of former,one of a most monstrous size...This came towards us,ON OF THE PSALMS."Touching that monstrous bulk of the...." ...
2.similar()函数; 可以用来查找与指定单词意义,用法相似的词,可以可以用在搜索引擎中的相关度识别功能中
>>>text1.similar("monstrous") Building word-context index... subtly impalpable pitiable curious imperrial perilous trustworthy abundant untoward singular lamentable few maddens horrible loving lazy mystifying christan exasperate puzzled
3.common_contexts()函数 ;可以用来研究共用两个或两个以上词汇的上下文
>>>text2.common_contexts(["monstrous","very"]) be_gald am_glad a_pretty a_lucky >>>注:有时monstrous和very一样,作强调作用。
4.generate()函数;用于随机生成文本
>>>text3.generate() In the beginning of his brother is a hairyman,whose top may reach unto heaven... >>>
注:本文中所有代码均来自《Python自然语言处理》(Steven bird,Ewan Klein&Edward Loper)
相关文章推荐
- NLTK之搜索文本的相关入门函数(二)
- javascript入门·表单和表单元素二 (文本相关,按钮,单、复选按钮)
- gdi、gdi+文本相关函数
- 语义相关app搜索(二) 论短文本相似——qjzcy的博客
- C 语言相关函数入门
- PHP学习笔记——PHP数组中键和值搜索的相关函数1
- 文本操作相关函数
- PHP学习笔记——PHP数组中和键值搜索相关的函数2
- postgresql----文本搜索类型和检索函数
- Elasticsearch in java范例:索引文本数据、搜索文本数据入门
- HEVC函数入门(14)——建议先看:整个编码流程以及相关的函数
- 文件磁盘相关函数[5]-搜索文件 FindFirst; FindNext; FindClose
- MFC学习笔记 文本编程及相关函数
- 以文本方式输出函数执行时间相关信息
- 【OpenCV笔记 05】OpenCV插入文本和字体设置相关函数
- 基本上包含了Foudation框架内的所有函数和方法。 使用方法:全选,自己建一个文本类的文件,如果要使用某个方法却想不起来方法名,直接在文本中搜索关键字即可。
- javascript入门·表单和表单元素二 (文本相关,按钮,单、复选按钮)
- javascript入门·表单和表单元素二 (文本相关,按钮,单、复选按钮) .txt
- C语言学习入门 (四) 字符串、字符串数组、字符和字符串相关函数
- MySQL入门之时间相关函数