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
私は理解していませんエラー。
あなたの問題は間違いなくインデントが原因です。あなたの実際の問題よりもここでは間違っていると思います。 –
インデントに加えて、return文もありますが、関数定義はありません。あなたはdef funcname(入力)を持っていますか:? – Kelvin
さて、関数の外に 'return'があります。混乱するのは何ですか? –