def loadDataset(fileName):
with open(fileName, 'rU') as trainingInput:
# detect the "dialect" of this type of csv file
try:
dialect = csv.Sniffer().sniff(trainingInput.read(1024))
except:
# if we fail to detect the dialect, defautl to Microsoft Excel
dialect = 'excel'
trainingInput.seek(0)
trainingRows = csv.reader(trainingInput, dialect)
allTweets = []
allTweetSentiments = []
entireDataset = []
for row in trainingRows:
# csv only gives us an iterable, not the data itself
entireDataset.append(row)
return entireDataset
评论列表
文章目录