'string' 的类型不正确(应为 str,得到 spacy.tokens.doc.Doc)
'string' has incorrect type (expected str, got spacy.tokens.doc.Doc)
我有一个数据框:
train_review = train['review']
train_review
看起来像:
0 With all this stuff going down at the moment w...
1 \The Classic War of the Worlds\" by Timothy Hi...
2 The film starts with a manager (Nicholas Bell)...
3 It must be assumed that those who praised this...
4 Superbly trashy and wondrously unpretentious 8...
我将标记添加到字符串中:
train_review = train['review']
train_token = ''
for i in train['review']:
train_token +=i
我想要的是使用 Spacy 对评论进行标记。
这是我尝试过的方法,但出现以下错误:
Argument 'string' has incorrect type (expected str, got
spacy.tokens.doc.Doc)
我该如何解决?提前致谢!
在您的 for
循环中,您从数据框中获取 spacy.tokens 并将它们附加到一个字符串,因此您应该将其转换为 str
。
像这样:
train_review = train['review']
train_token = ''
for i in train['review']:
train_token += str(i)
我有一个数据框:
train_review = train['review']
train_review
看起来像:
0 With all this stuff going down at the moment w...
1 \The Classic War of the Worlds\" by Timothy Hi...
2 The film starts with a manager (Nicholas Bell)...
3 It must be assumed that those who praised this...
4 Superbly trashy and wondrously unpretentious 8...
我将标记添加到字符串中:
train_review = train['review']
train_token = ''
for i in train['review']:
train_token +=i
我想要的是使用 Spacy 对评论进行标记。 这是我尝试过的方法,但出现以下错误:
Argument 'string' has incorrect type (expected str, got spacy.tokens.doc.Doc)
我该如何解决?提前致谢!
在您的 for
循环中,您从数据框中获取 spacy.tokens 并将它们附加到一个字符串,因此您应该将其转换为 str
。
像这样:
train_review = train['review']
train_token = ''
for i in train['review']:
train_token += str(i)