【发布时间】:2018-12-18 19:02:12
【问题描述】:
我试图在每行由多行字符串组成的数据框中找到常用词。
from nltk.tokenize import word_tokenize
from nltk.tokenize import sent_tokenize
tokens = [word for sent in nltk.sent_tokenize(df['file_data'].to_string()) for
word in nltk.word_tokenize(sent)]
在这里,(...) 是最常用的词,但实际上它不会出现在任何行中。 默认情况下,笔记本上的多行打印 (...) 表示延续。 但是,问题是 nltk 将 (...) 视为单词并以此结尾。 它跳过字符串中的剩余单词。 请让我知道我在哪里失踪,提前谢谢。
【问题讨论】:
标签: python jupyter-notebook nltk google-colaboratory