使用下面的代码时,我只得到整个列的一个输出。但是我想要每一行的输出。我想知道我该怎么做?这是我从数据帧转换的字符串
from textblob.classifiers import DecisionTreeClassifier
train = [('I love this sandwich.', 'pos'),
('This is an amazing place!', 'pos'),
('I feel very good about these beers.', 'pos'),
('I do not like this restaurant', 'neg'),
('I am tired of this stuff.', 'neg'),
("I can't deal with this", 'neg'),
("My boss is horrible.", "neg")
]
ho=tweets['twt'] % where tweets['twt'] contains tweets in text format
a=ho.to_string(buf=None, columns=None, col_space=None, header=True, index=True, na_rep='NaN', formatters=None, float_format=None, sparsify=False, index_names=True, justify=None, line_width=None, max_rows=None, max_cols=None, show_dimensions=False)
cl = DecisionTreeClassifier(train)
blob = TextBlob(a, classifier=cl)
for s in blob.sentences:
print(s)
print(s.classify())
目前没有回答
相关问题 更多 >
编程相关推荐