[英]How to apply TFIDF on nltk POS Data …?
I applied nltk POS featurization to my reviews column in my panda's DataFrame.我将 nltk POS 特征化应用于我的熊猫 DataFrame 中的评论列。 I got the new feature, but when I'm trying to apply TFIDF vectorization on that feature it shows error like我得到了新功能,但是当我尝试在该功能上应用 TFIDF 矢量化时,它显示错误,例如
Error: While applying TFIDF Vectorizer错误:应用 TFIDF Vectorizer 时
AttributeError: 'list' object has no attribute lower AttributeError: 'list' object 没有属性 lower
I used below code for nltk POS我将以下代码用于 nltk POS
pure_df['pre_pro_plot_synopsis_POS'] = pos_tag_sents(pure_df['pre_pro_plot_synopsis'].apply(word_tokenize).tolist())
Can anyone help me to pass POS data to tfidf vectorizer?谁能帮我将 POS 数据传递给 tfidf 矢量化器?
Thank's in advance提前致谢
Here it seems pos_tag_sents
method created by you expects a string as paramenter, but here you are passing list as a parameter to it.在这里,您创建的pos_tag_sents
方法似乎需要一个字符串作为参数,但在这里您将列表作为参数传递给它。 So instead of this line: pos_tag_sents(pure_df['pre_pro_plot_synopsis'].apply(word_tokenize).tolist())
所以代替这一行: pos_tag_sents(pure_df['pre_pro_plot_synopsis'].apply(word_tokenize).tolist())
Try using apply method again and pass pos_tag_sents
to it, like this:再次尝试使用 apply 方法并将pos_tag_sents
传递给它,如下所示:
pure_df['pre_pro_plot_synopsis_POS'] = pure_df['pre_pro_plot_synopsis'].apply(word_tokenize).apply(pos_tag_sents).tolist()
Hope it helps.希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.