-5

nltk のいくつかの単語を単純に分類しようとしています。

contains(want) = True positi : negati = 1.7 : 1.0
contains(great) = True positi : negati = 1.7 : 1.0
contains(love) = False negati : positi = 1.4 : 1.0
contains(die) = False positi : negati = 1.2 : 1.0
contains(live) = False negati : positi = 1.2 : 1.0
contains(terrible) = False positi : negati = 1.2 : 1.0

ただし、で構文エラーが発生しpositiます。

4

1 に答える 1

2

基本的な python 構文に追いつく必要があります。あなたが本当に欲しいのは次のようなものだと思います:

if contains('want'): positi, negati = 1.7, 1.0

これは、True 値を返すときに1.7topositi1.0to を代入します。などはここでは変数名ではなく、リテラル文字列である必要があると想定しています。negaticontains('want')wantgreater

于 2013-09-16T07:16:52.807 に答える