![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
NLP
文章平均质量分 53
记录NLP的学习过程,主要用python实现
Stranger_Laity
这个作者很懒,什么都没留下…
展开
-
NLTK的使用
from nltk.book import * #使用nlp工具包 text1.concordance(“monstrous”) #搜索文本,看到词的上下文 text1.similar(“monstrous”)#搜索词的上下文,查找还有哪些词出现在相似的上下文中,以此判断该词在文中的意思 函数common_contexts允许我们研究两个或两个以上的词共同的上下文,如monstrous和very。我们必须用方括号和圆括号把这些词括起来,中间用逗号分割。 text2.common_contexts([“原创 2021-01-26 16:07:07 · 633 阅读 · 0 评论 -
python初接触
split() 通过指定分隔符对字符串进行切片,如果参数 num 有指定值,则分隔 num+1 个子字符串 str = “Line1-abcdef \nLine2-abc \nLine4-abcd”; print str.split( ); # 以空格为分隔符,包含 \n print str.split(’ ', 1 ); # 以空格为分隔符,分隔成两个 以上实例输出结果如下: [‘Line1-abcdef’, ‘Line2-abc’, ‘Line4-abcd’] [‘Line1-abcdef’原创 2021-01-26 16:04:34 · 103 阅读 · 0 评论