# Name: # Date: # Description: # # import math, os, pickle from DataReader import * class BayesClassifier: def __init__(self): '''This method initializes and the Naive Bayes Classifier.'' def train(self, dataFile): '''Trains the Naive Bayes Sentiment Classifier.''' def classify(self, sText): '''Given a target string sText, this function returns the most likely document class to which the target string belongs (i.e., positive or negative ). ''' def save(self, sFilename): '''Save the learned data during training to a file using pickle.''' f = open(sFilename, "w") p = pickle.Pickler(f) # use dump to dump your variables #p.dump(self.var1) #p.dump(self.var2) #p.dump(self.var3) f.close() def load(self, sFilename): '''Given a file name of stored data, load and return the object stored in the file.''' f = open(sFilename, "r") u = pickle.Unpickler(f) # use load to load in previously dumped variables #self.var1 = u.load() #self.var2 = u.load() #self.var3 = u.load() f.close()