def train(self, numIterations=100, testCorpusPath=None): if testCorpusPath: testCorpus = Corpus(testCorpusPath) for i in range(1, numIterations + 1): self.algorithm.train() # call train method from algorithm if i % 10 == 0: # trainEval = Evaluation(self.algorithm.corpus) # print "Training evaluation for", i, "iteration(s):\n", trainEval.format() # self.algorithm.corpus.resetSentStats() if testCorpusPath: self.setPredictedTags(testCorpus) testEval = Evaluation(testCorpus) print "Testing evaluation for", i, "iteration(s):\n",testEval.format() testCorpus.resetSentStats() # !!! we can use prototype pattern(so we don't need to loop through sents): here testCorpus = testCorpus.getPrototype() and in Corpus::__init__ : self.prototype = self (google : python prototype)?
def train(self, numIterations=100, testCorpusPath=None): if testCorpusPath: testCorpus = Corpus(testCorpusPath) for i in range(1, numIterations + 1): self.algorithm.train() # call train method from algorithm if i % 10 == 0: # trainEval = Evaluation(self.algorithm.corpus) # print "Training evaluation for", i, "iteration(s):\n", trainEval.format() # self.algorithm.corpus.resetSentStats() if testCorpusPath: self.setPredictedTags(testCorpus) testEval = Evaluation(testCorpus) print "Testing evaluation for", i, "iteration(s):\n", testEval.format( ) testCorpus.resetSentStats( ) # !!! we can use prototype pattern(so we don't need to loop through sents): here testCorpus = testCorpus.getPrototype() and in Corpus::__init__ : self.prototype = self (google : python prototype)?