Example #1
0
	def createEvaluationfiles(self, dirCorpus, testPercentage, numberOfPartition, bibl_list):
		dirPartitions = self.getDirPartitionNames()
		for dirPartition in dirPartitions:
			(annotateDir, testDir, trainDir, modelDir, _) = self.getDirTestNames(dirPartition)
			testCorpus, trainCorpus = FormatEval.getShuffledCorpus(bibl_list, testPercentage)
			#print testCorpus
			#print trainCorpus
			
			# files used for training (100 - testPercentage % of the corpus)
			FormatEval.copy_files_for_eval(self.dirCorpus, trainDir, trainCorpus)
			# files used for evaluation keeping annotations (testPercentage % of the corpus)
			FormatEval.copy_files_for_eval(self.dirCorpus, testDir, testCorpus)
			# files used for evaluation, strip the annotations
			# they will be labeled by bilbo
			FormatEval.copy_files_for_eval(self.dirCorpus, annotateDir, testCorpus, 'bibl', strip=True)
Example #2
0
	def createEvaluationfiles(self, dirCorpus, testPercentage, numberOfPartition, allBibl):
		dirPartitions = self.getDirPartitionNames()
		for dirPartition in dirPartitions:
			(annotateDir, testDir, trainDir, modelDir, _) = self.getDirTestNames(dirPartition)
			testCorpus, trainCorpus = FormatEval.getShuffledCorpus(allBibl, testPercentage)
			
			trainFile = os.path.join(trainDir, 'train.xml')
			self.saveListToFile(trainCorpus, trainFile)
			
			cleanCorpus = FormatEval.stripTags(testCorpus)
			cleanFile = os.path.join(annotateDir, 'test_clean.xml')
			self.saveListToFile(cleanCorpus, cleanFile)

			# In test.xml we need to duplicate <bibl> inside <bibl>, in order to present the same data for evaluation
			# Bilbo does not format the "same" data equaly between train and annotation
			evalFile = os.path.join(testDir, 'test.xml')
			testCorpus = FormatEval.getBiblList("\n".join(testCorpus))
			self.saveListToFile(testCorpus, evalFile)