for x in non_neutral.collect():
tweet = str(x[2])
sid = x[1]
status = x[0]
text = word_tokenize(tweet)
text1 = list(text)
tweet = x[2].split()
pronoun = intersect(second_pronoun,tweet)
perojective = intersect(less_offensive,tweet)
if pronoun:
pronoun_index = tweet.index(pronoun[0])
pero_index = tweet.index(perojective[0])
if pero_index <= pronoun_index+3:
status = 1
return Row(status=status,tid=sid,tweet = str(tweet))
else:
status = 0
return Row(status=status,tid=sid,tweet = str(tweet))
返回的代码,我经常收到这个错误,这个特殊的代码片段,我不明白为什么的Python:外功能错误
File "<ipython-input-5-0484b7e6e4fa>", line 15
return Row(status=status,tid=sid,tweet = str(tweet))
SyntaxError: 'return' outside function
我试图重新编写代码,但仍然得到同样的错误。
你的问题肯定是由于缩进。我认为在这里比在实际问题中更加错误 –
除了缩进之外,您还有返回语句,但没有函数定义。你有一个def funcname(输入):? – Kelvin
那么,你有一个函数外的'return'。什么让人困惑? –