Nlp 名称错误:名称';干净的文本';没有定义

Nlp 名称错误:名称';干净的文本';没有定义,nlp,data-science,countvectorizer,Nlp,Data Science,Countvectorizer,我正在学习如何实现nlp,所以我从数据清理开始,现在我正在尝试使用文字包对数据进行矢量化,这是我的代码 import pandas as pd import numpy as np import string import re import nltk stopword=nltk.corpus.stopwords.words('english') wn=nltk.WordNetLemmatizer() from sklearn.feature_extraction.text import Cou

我正在学习如何实现nlp,所以我从数据清理开始,现在我正在尝试使用文字包对数据进行矢量化,这是我的代码

import pandas as pd
import numpy as np
import string
import re
import nltk
stopword=nltk.corpus.stopwords.words('english')
wn=nltk.WordNetLemmatizer()
from sklearn.feature_extraction.text import CountVectorizer


count_vect=CountVectorizer(analyzer=clean_text)
x_count=count_vect.fit_transform(lematizing_words)
print(x_count.shape)
但是,当我运行这段代码时,我得到了以下错误

NameError:未定义名称“clean_text”

我怎样才能解决这个问题


我已经在博客中介绍了nlp的实现

错误消息很好地描述了您的问题。什么是清洁文本?您是否定义了
clean_text
功能?还是导入了包含此函数的正确python模块

错误消息很好地描述了您的问题。什么是清洁文本?您是否定义了
clean_text
功能?还是导入了包含此函数的正确python模块

def cleanText(text):
    text = "".join([word.lower() for word in text if word not in string.punctuation])
    tokens = re.split('\W+', text)
    text = [ps.stem(word) for word in tokens if word not in stopwords]
    return text

stopwords = nltk.corpus.stopwords.words('english')
下面是Badreesh放入github但不在博客中的函数


这是Badreesh放在github中但不在博客中的函数。

我不知道,我下面的博客有一行“count\u vect=CountVectorizer(analyzer=clean\u text)”用于预测使用NLP的结果。blog link()我不知道,我下面的博客有一行“count\u vect=CountVectorizer(analyzer=clean\u text)”用来预测NLP的使用。博客链接()