def __init__( self ):
		self.driver = webdriver.Firefox()
		self.classifier = cf.classifier()
		self.URLs = []
		self.contexts = []

		self.bag = utils.load_dictionary()
		self.tagger = Mecab()
Beispiel #2
0
	def __init__(self):
		# initalize Mecab tagger
		self.tagger = Mecab()
	
		# initalize regular expression	
		self.exp = re.compile(self.POS, re.IGNORECASE)
		
		# load sentiment dictionary
		self.bag = utils.load_dictionary()
	
		# load model if exist
		with open("../Resources/models/model", "rb") as model_file:
			self.model = pickle.load(model_file)
Beispiel #3
0
	print("accuracy : {:.2f}%" .format(err))
	print("TPR : {:.2f}%" .format(100*(tp/r_pos)))
	print("TNR : {:.2f}%" .format(100*(tn/r_neg)))
			

if __name__ == "__main__":
	global POS
	
	# initalize Mecab tagger
	tagger = Mecab()

	# initalize regular expression	
	exp = re.compile(POS, re.IGNORECASE)
	
	# load sentiment dictionary
	bag = utils.load_dictionary()

	# load model if exist
	try:
		with open("../Resources/models/model", "rb") as model_file:
			model = pickle.load(model_file)
	except IOError as err:
		# load training reviews from file	
		train_review = utils.load_reviews("../Resources/samples/train_data")
		# get feature from train data
		train_data, train_label = feature_data(tagger, exp, bag, train_review)
		# initalize classifer class
		model = SVM()
		# train model
		model.train(train_data, train_label)
		#save model