我在python中有一个函数,它使用标记器将句子拆分为单词。 问题是,当我运行这个函数时,返回的输出是一个没有空格的字
是爱的图片2生活网!!!Y所有有趣的应用程序r iphone而不是黑莓??”
“IsLovinPictureLifeComyallfunsr适用于iPhone而非黑莓”
结果必须如下所示: 是一幅充满爱的人生画卷。com…
ppt = '''...!@#$%^&*()....{}’‘ “” “[]|._-`/?:;"'\,~12345678876543'''
#tekonize helper function
def text_process(raw_text):
'''
parameters:
=========
raw_text: text as input
functions:
==========
- remove all punctuation
- remove all stop words
- return a list of the cleaned text
'''
#check characters to see if they are in punctuation
nopunc = [char for char in list(raw_text) if char not in ppt]
# join the characters again to form the string
nopunc = "".join(nopunc)
#now just remove ant stopwords
words = [word for word in nopunc.lower().split() if word.lower() not in stopwords.words("english")]
return words
ddt= data.text[2:3].apply(text_process)
print("example: {}".format(ddt))
嗯,在你的第一行
在
‘ “” “
序列中包含空格字符,因此它在运行列表时删除了所有空格(因此也删除了空格):
相关问题 更多 >
编程相关推荐