# ----------------------------------------------------------------- # if __name__ == '__main__': # file names trainingFileA = 'trainA.txt' trainingFileB = 'trainB.txt' # parse training and testing data trainA, testA = parseA(trainingFileA, 5) trainB, testB = parseB(trainingFileB, 5) # decision list print '\nDECISION LIST Part 5' tagsA = decisionList(trainA, testA) tagsB = decisionList(trainB, testB) checkTagsA(tagsA, testA) checkTagsB(tagsB, testB) # parse training and testing data trainA, testA = parseA(trainingFileA, 4) trainB, testB = parseB(trainingFileB, 4) # decision list print '\nDECISION LIST Part 4' tagsA = decisionList(trainA, testA) tagsB = decisionList(trainB, testB) checkTagsA(tagsA, testA) checkTagsB(tagsB, testB) # parse training and testing data trainA, testA = parseA(trainingFileA, 3)
# ----------------------------------------------------------------- # if __name__ == "__main__": # file names trainingFileA = "trainA.txt" trainingFileB = "trainB.txt" # parse training and testing data trainA, testA = parseA(trainingFileA, 5) trainB, testB = parseB(trainingFileB, 5) # decision list print "\nDECISION LIST Part 5" tagsA = decisionList(trainA, testA) tagsB = decisionList(trainB, testB) checkTagsA(tagsA, testA) checkTagsB(tagsB, testB) # parse training and testing data trainA, testA = parseA(trainingFileA, 4) trainB, testB = parseB(trainingFileB, 4) # decision list print "\nDECISION LIST Part 4" tagsA = decisionList(trainA, testA) tagsB = decisionList(trainB, testB) checkTagsA(tagsA, testA) checkTagsB(tagsB, testB) # parse training and testing data trainA, testA = parseA(trainingFileA, 3)
# determine the number of weighted words in the tweet for position in lexicon[word].keys(): if lexicon[word][position]['polar'] == 'positive': pos += 1 elif lexicon[word][position]['polar'] == 'negative': neg += 1 # tag the tweet if pos > neg: tagsB[ID][subject] = 'positive' elif pos < neg: tagsB[ID][subject] = 'negative' else: tagsB[ID][subject] = 'objective' return tagsA, tagsB # ----------------------------------------------------------------- # if __name__ == '__main__': trainingFileA = 'trainA.txt' trainingFileB = 'trainB.txt' lexiconFile = 'sentimentLexicon.txt' trainA, testA = parseA(trainingFileA) trainB, testB = parseB(trainingFileB) lexicon = getSentimentWords(lexiconFile) tagsA, tagsB = lexiconTag(trainA, trainB, lexicon) checkTagsA(tagsA,trainA) checkTagsB(tagsB,trainB) # ----------------------------------------------------------------- #