python - 关于 nltk 中的 vocab() 和 Text()
问题描述
以下代码有什么作用?即,只是最后两行。我不明白 Text() 做什么以及 vocab() 做什么?
import nltk
def words(content):
tokens = nltk.tokenize.word_tokenize(content) #Make the string into a list of words
tokens = [w for w in tokens if not w in stop_words] # remove the stop words
tokens = [wordnet_lemmatizer.lemmatize(w) for w in tokens] #Lemmatization
NLTKText = Text(tokens)## remove if nltk is restricted develop new method
return NLTKText.vocab()
运行后我得到的是一些数据结构 FreqDist。
解决方案
推荐阅读
- php - 实时提交html表单信息到其他网站
- python - 为什么我不能循环保存图像?
- javascript - clipboard.js ios12 UIWebView 无法复制
- python - 如何使用 Python API 删除 Cassandra 中的记录?
- logic - 一阶逻辑和猜想范式
- android - 空对象引用上的 Android ViewPager
- data-partitioning - dolphindb分布式数据库无法写入数据
- elasticsearch - 3 节点 Elasticsearch 集群 V 7xxx
- c# - 重定向到另一个页面时出现 ASP .NET 错误:试图读取或写入受保护的内存。这通常表明其他内存已损坏
- reactjs - 当我单击 React 中的完成按钮时如何删除帖子