“我的数据框架”中的一列包含以下文本:
'This is very good. No it is very bad. Actually it is alright'
我想对本专栏中的文本进行句子标记,主要是创建一个嵌套的句子列表
我试过了
def tokenizeAndList(text):
raw_text = text
nlp = English()
nlp.add_pipe(nlp.create_pipe('sentencizer')) # updated
doc = nlp(raw_text)
sentences = [sent.string.strip() for sent in doc.sents]
return(sentences)
out=myText['findings'].map(tokenizeAndList)
这给了我一个错误:
TypeError: object of type 'NAType' has no len()
如何创建嵌套列表
这是因为
findings
列中的某些值不是字符串类型在使用该
text
创建空间文档之前,应检查其类型是否为str
,否则按原样返回值:相关问题 更多 >
编程相关推荐