def doMetrics(Display=False, WS=False, Ver=2): utils = Utils(Display=Display, WS=WS, Ver=Ver) c = Clasificator(Ver=Ver) if Ver == 2: base_save = "./res/statistics/Metrics" else: base_save = "./res/statistics2/Metrics" (posWords, negWords, posI, negI, tokenizedComm) = utils.process() matrix = {} for i in range(0, 30): train_path = "./resources/statistic/train" + str(i) + ".txt" test_path = "./resources/statistic/test" + str(i) + ".txt" (Metrics, num) = c.process(posWords, negWords, posI, negI, tokenizedComm, train_path, test_path) c.saveMetrics(Metrics, base_save + str(i) + ".txt") matrix[i] = num return matrix
posWords = [word for (word, val) in mydicposSorted] negWords = [word for (word, val) in mydicnegSorted] return (posWords, negWords, list(positiveI), list(negativeI), tokenizedComm) if __name__ == "__main__": display = False ws = False ver = 2 try: opts, args = getopt.getopt(sys.argv[1:], "wdv", []) except getopt.GetoptError: print "Invalid arguments" sys.exit(2) for opt, arg in opts: if opt == "-w": print "Webservice Mode" ws = True elif opt == "-d": display = True elif opt == "-v": ver = 1 utils = Utils(Display=display, WS=ws, Ver=ver) classify = Clasificator(Ver=ver) (posWords, negWords, posI, negI, tokenizedComm) = utils.process() (train, test) = classify.load_train_test_set() (Metrics, num) = classify.process(posWords, negWords, posI, negI, tokenizedComm) classify.saveMetrics(Metrics)