我想创建一个 .arff 文件,显示我的 python 代码中最有用的 10 个单词。格式应该是这样的。
@attribute pattern1 {yes,no}
@attribute pattern2 {yes,no}
......
.......
@attribute emotion {angry,disgusted,fearful,happy,sad,surprised}
@data
yes, no, no,......, yes, happy
no, no, no,....., no, angry
yes, yes, no,......, yes, sad
每行应包含 10 个“真”或“假”值的列表,然后是一种情绪。
这是我到目前为止所写的,但它没有按要求显示。请帮帮我。
f = open("emotions.txt", "w")
f.write('''@RELATION Emotions\n
@ATTRIBUTE word{yes,no}
@ATTRIBUTE class {angry,sad,happy,surprised,fearful,disgusted}
@DATA\n''')
for word in varall:
f.write("%s\n" %word)
f.close()