示例#1
0
    def run(self, _type, _isUnion=False, _featureFile=None):
        '''
		create result file
		'''
        self.TYPE = _type
        print(_type)
        # XLS preparing
        self.summarySheet = self.create_SummarySheet(0)
        self.subjectSheet = self.create_SubjectSheet(0)
        self.dataSheet = self.create_DataSheet(0)
        self.bugSheet = self.create_bugDataSheet(0)

        self.S = Subjects()
        for group in self.S.groups:  #['Commons', 'JBoss', 'Wildfly', 'Spring']
            for project in self.S.projects[group]:
                #if project not in ['HBASE','HIVE','ROO','SEC', 'SPR']:continue   #
                print(u'working %s / %s ...' % (group, project), end=u'')

                # fill Dup and subjects
                self.fill_SubjectSheet(self.subjectSheet, group, project,
                                       self.S.sources[project],
                                       self.S.bugs[project],
                                       len(self.S.duplicates[project]))

                for tech in self.S.techniques:  #['BLIA']:#  ['BugLocator', "BRTracer", 'BLUiR', 'BLIA']:#, 'Locus']:#
                    print(tech + u' ', end=u'')
                    self.append_project(group, project, tech, _isUnion)
                print(u' Done')
        self.finalize()
        pass
示例#2
0
    def __init__(self):
        self.S = Subjects()
        if not os.path.exists(os.path.join(self.ProgramPATH, 'logs')):
            os.makedirs(os.path.join(self.ProgramPATH, 'logs'))

        t = datetime.now()
        timestr = t.strftime(u'%y%m%d_%H%M')
        self.logFileName = u'logs_%s' % timestr + u'_%s.txt'
示例#3
0
def make(_sGroup=None, _sProject=None):
    S = Subjects()
    for group in S.groups:
        if _sGroup is None or group == _sGroup:
            for project in S.projects[group]:
                if _sProject is None or project == _sProject:
                    git = GitInflator(project, S.getPath_base(group, project))
                    git.inflate(
                        S.versions[project]
                    )  # The items in versions is git tag name map with each version.
示例#4
0
def work(_sGroup=None, _sProject=None, _removeTest=True):
    S = Subjects()
    for group in (S.groups if _sGroup is None else [_sGroup]):
        for project in (S.projects[group]
                        if _sProject is None else [_sProject]):
            obj = BugRepositoryMaker(project,
                                     S.getPath_bugrepo(group, project),
                                     S.getPath_gitrepo(group, project),
                                     S.getPath_bugrepo(group, project))
            obj.run(S.versions[project].keys(), _removeTest)
示例#5
0
def make(_sGroup=None, _sProject=None):
    S = Subjects()
    for group in S.groups:
        if _sGroup is not None and group != _sGroup: continue
        for project in S.projects[group]:
            if _sProject is not None and project != _sProject: continue
            git = GitInflator(project, urls[project],
                              S.getPath_base(group, project))
            git.inflate(
                S.versions[project]
            )  # The items in versions is git tag name map with each version.
示例#6
0
def clear(_sGroup=None, _sProject=None):
    S = Subjects()
    for group in S.groups:
        if _sGroup is not None and group != _sGroup: continue
        for project in S.projects[group]:
            if _sProject is not None and project != _sProject: continue
            target = S.getPath_source(group, project)
            try:
                shutil.rmtree(target, onerror=del_rw)
                print(u'removed: %s' % target)
            except Exception as e:
                print(u'failed to remove : %s' % target)
示例#7
0
	def run(self, _type, _isUnion=False):
		'''
		create result file
		'''
		self.TYPE = _type
		print(_type)

		self.S = Subjects()
		self.OverallResult = {}
		for tech in self.S.techniques:
			self.OverallResult[tech] = {'master': {'AP': [], 'TP': []}, 'duplicate': {'AP': [], 'TP': []}}

		# XLS preparing
		shtOverall = self.create_OverallSheet(0)
		shtMasterSummary, rowMasterSummary = self.create_SummarySheet(u'Summary (Master)', 0)
		shtMasterBugData, rowMasterBugData = self.create_bugDataSheet(u'bugData (Master)', 0)
		shtMasterData, rowMasterData = self.create_DataSheet(u'rawData (Master)', 0)

		shtDupSummary, rowDupSummary = self.create_SummarySheet(u'Summary (Dup)', 0)
		shtDupBugData, rowDupBugData = self.create_bugDataSheet(u'bugData (Dup)', 0)
		shtDupData, rowDupData = self.create_DataSheet(u'rawData (Dup)', 0)

		for group in self.S.groups:
			for project in self.S.projects[group]:
				print(u'working %s / %s ...' % (group, project), end=u'')

				for tech in self.S.techniques:
					print(tech + u' ', end=u'')
					evMaster, evDuplicate = self.load_results(group, project, tech, _isUnion)

					masterBugs, dupBugs = self.make_IDsets(self.S.duplicates[project])
					rowMasterSummary = self.fill_SummarySheet(shtMasterSummary, rowMasterSummary, tech, group, project, 'master', evMaster.projectSummary, self.S.sources[project]['max'], len(masterBugs), len(evMaster.bugSummaries))
					rowMasterBugData = self.fill_bugDataSheet(shtMasterBugData, rowMasterBugData, tech, group, project, 'master', evMaster.bugSummaries, self.S.answers[project]['all'])
					rowMasterData = self.fill_DataSheet(shtMasterData, rowMasterData, tech, group, project, 'master', evMaster.bugSummaries, evMaster.rawData, self.S.sources[project], self.S.answers[project]['all'])

					rowDupSummary= self.fill_SummarySheet(shtDupSummary, rowDupSummary, tech, group, project, 'duplicate', evDuplicate.projectSummary, self.S.sources[project]['max'], len(dupBugs), len(evDuplicate.bugSummaries))
					rowDupBugData = self.fill_bugDataSheet(shtDupBugData, rowDupBugData, tech, group, project, 'duplicate', evDuplicate.bugSummaries, self.S.answers[project]['all'])
					rowDupData = self.fill_DataSheet(shtDupData, rowDupData, tech, group, project, 'duplicate', evDuplicate.bugSummaries, evDuplicate.rawData, self.S.sources[project], self.S.answers[project]['all'])

					for bugID in evMaster.bugSummaries:
						self.OverallResult[tech]['master']['AP'].append(evMaster.bugSummaries[bugID].AP)
						self.OverallResult[tech]['master']['TP'].append(evMaster.bugSummaries[bugID].TP)

					for bugID in evDuplicate.bugSummaries:
						self.OverallResult[tech]['duplicate']['AP'].append(evDuplicate.bugSummaries[bugID].AP)
						self.OverallResult[tech]['duplicate']['TP'].append(evDuplicate.bugSummaries[bugID].TP)

				print(u' Done')

		self.fill_OverallSheet(shtOverall)
		self.finalize()
		pass
示例#8
0
def clean():
	S = Subjects()
	for group in S.groups:
		for project in S.projects[group]:
			print(u'cleanning %s / %s ' % (group, project))
			dirpath = os.path.join(S.getPath_bugrepo(group, project), u'repository_merge')
			fullrepo = os.path.join(S.getPath_bugrepo(group, project), u'repository_merge.xml')
			try:
				shutil.rmtree(dirpath)
			except Exception as e:
				print(u'Failed to remove repository folder')
			try:
				os.remove(fullrepo)
			except Exception as e:
				print(u'Failed to remove full repository file')
	pass
    def make(self, _group, _project):
        '''
		make repository files
		:param _group:
		:param _project:
		:return:
		'''
        self.S = Subjects()

        print(u'working with %s / %s' % (_group, _project))
        filename = os.path.join(self.S.getPath_bugrepo(_group, _project),
                                u'repository.xml')
        bugs = self.load_bugs(filename)
        dups = self.S.duplicates[_project]

        merges = self.merge(_group, _project, bugs, dups)
        print(u'created %d merged reports.' % len(merges))

        versionItems = self.getItemsByVersion(merges,
                                              self.S.versions[_project].keys())
        print(u'created %d version repositories from merged reports.' %
              len(versionItems))

        print(u'storing....', end=u'')
        repositoryPath = os.path.join(self.S.getPath_bugrepo(_group, _project),
                                      u'repository_merge')
        if os.path.exists(repositoryPath) is True:
            shutil.rmtree(repositoryPath)
        if os.path.exists(repositoryPath) is False:
            os.makedirs(repositoryPath)

        self.outputXML(
            _project, merges,
            os.path.join(self.S.getPath_bugrepo(_group, _project),
                         u'repository_merge.xml'))
        for ver in versionItems.keys():
            filename = os.path.join(
                repositoryPath,
                VersionUtil.get_versionName(ver, _project) + u'.xml')
            self.outputXML(_project, versionItems[ver], filename)
        print(u'Done')

        answers = self.make_answers(_project, merges, versionItems)
        self.save_answers({_project: answers},
                          os.path.join(self.S.getPath_base(_group, _project),
                                       u'answers_merge.txt'))
        pass
示例#10
0
def clean(_sGroup=None, _sProject=None):
    S = Subjects()
    for group in (S.groups if _sGroup is None else [_sGroup]):
        for project in (S.projects[group]
                        if _sProject is None else [_sProject]):
            print(u'cleanning %s / %s ' % (group, project))
            tempfile1 = os.path.join(S.getPath_bugrepo(group, project),
                                     u'.git.log')
            tempfile2 = os.path.join(S.getPath_bugrepo(group, project),
                                     u'.git_version.txt')
            dirpath = os.path.join(S.getPath_bugrepo(group, project),
                                   u'repository')
            fullrepo = os.path.join(S.getPath_bugrepo(group, project),
                                    u'repository_full.xml')
            filteredrepo = os.path.join(S.getPath_bugrepo(group, project),
                                        u'repository.xml')
            try:
                os.remove(tempfile1)
            except Exception as e:
                print(u'Failed to remove git log')
            try:
                os.remove(tempfile2)
            except Exception as e:
                print(u'Failed to remove git versions')
            try:
                shutil.rmtree(dirpath)
            except Exception as e:
                print(u'Failed to remove repository folder')
            try:
                os.remove(fullrepo)
            except Exception as e:
                print(u'Failed to remove full repository file')
            try:
                os.remove(filteredrepo)
            except Exception as e:
                print(u'Failed to remove filtered repository file')
    pass
示例#11
0
def work():
    obj = DupMergeRepositoryMaker()
    S = Subjects()
    for group in S.groups:
        for project in S.projects[group]:
            obj.make(group, project)
示例#12
0
		for tech in techniques:
			for version in _versions:
				vname = VersionUtil.get_versionName(version, _project)
				src_path = os.path.join(_src, u'%s_%s_%s' % (tech, _project, vname), u'recommended')
				if os.path.exists(src_path) is False:
					print(u'%s is not exists!!'%src_path)
					continue
				target_path = os.path.join(_dest, tech, _group, _project, u'%s_%s' % (tech, vname))
				shutil.copytree(src_path, target_path)
				print(u'%s is Done!!' % src_path)
		pass


###############################################################################################################
###############################################################################################################
###############################################################################################################
if __name__ == "__main__":
	import os
	WorkType = u'Full'
	S = Subjects()
	for group in S.groups:  # ['Commons', 'JBoss', 'Wildfly', 'Spring']
		for project in S.projects[group]:

			obj = CopyResults()
			obj.run(group, project,
					S.versions[project],
					S.getPath_result_folder(WorkType, group, project),
					os.path.join(S.root_result, 'organize_full'))
	pass

示例#13
0
    def compare_multi_results(self, _basepath, _withoutTest=False):
        '''
		:param _basepath:
		:return:
		'''
        def get_average_mwu(_itemType):
            results = {}
            multi = os.path.join(
                _basepath, u'New_Multiple%s_%s.txt' %
                ('_noTest' if _withoutTest is True else '', _itemType))
            titles, dataM = self.load_results_items(multi, ['str'] * 3 +
                                                    ['float'] * 6)
            # MWUresults = {}
            # single = os.path.join(_basepath, u'New_Single_%s.txt' % _itemType)
            # titles, dataS = self.load_results_items(single, ['str'] * 3 + ['float'] * 6)
            for group in dataM:
                if group not in results: results[group] = {}
                #if group not in MWUresults: MWUresults[group] = {}
                for project in dataM[group]:
                    CNTs = dict(zip(titles, CNTdata[group][project]))
                    results[group][project] = self.get_technique_averages(
                        dataM[group][project], CNTs)
                    #MWUresults[group][project] = self.MWUtest(dataS[group][project], dataM[group][project], CNTs, CNTs)

            return results  #, MWUresults

        techinques, CNTdata = self.load_results(
            os.path.join(_basepath, u'BugCNT.txt'), ['str'] * 2 + ['int'] * 6)

        APresults = get_average_mwu('AP')
        TPresults = get_average_mwu('TP')

        print(u'')
        print(u'\t' + u'\t\t'.join(self.techniques))
        print(
            u'Subject\tMAP\tMRR\tMAP\tMRR\tMAP\tMRR\tMAP\tMRR\tMAP\tMRR\tMAP\tMRR'
        )
        S = Subjects()
        for group in S.groups:
            for project in S.projects[group]:
                text = u'%s' % project
                APmax = self.get_max_technique(APresults[group][project],
                                               self.techniques)
                TPmax = self.get_max_technique(TPresults[group][project],
                                               self.techniques)

                for tech in self.techniques:
                    text += self.make_max_text(APresults[group][project][tech],
                                               APmax == tech, u'blue!25')
                    text += self.make_max_text(TPresults[group][project][tech],
                                               TPmax == tech, u'green!25')
                text += u' \\\\'
                print(text)

        # make average information
        avgAPs = dict(zip(self.techniques, [0] * len(self.techniques)))
        avgTPs = dict(zip(self.techniques, [0] * len(self.techniques)))
        for tech in self.techniques:
            count = 0
            for group in S.groups:
                count += len(S.projects[group])
                avgAPs[tech] += sum(APresults[group][project][tech]
                                    for project in S.projects[group])
                avgTPs[tech] += sum(TPresults[group][project][tech]
                                    for project in S.projects[group])
            avgAPs[tech] /= count
            avgTPs[tech] /= count

        text = u'Average'
        APmax = self.get_max_technique(avgAPs, self.techniques)
        TPmax = self.get_max_technique(avgTPs, self.techniques)
        for tech in self.techniques:
            text += self.make_max_text(avgAPs[tech], APmax == tech, u'blue!25')
            text += self.make_max_text(avgAPs[tech], TPmax == tech,
                                       u'green!25')
        text += u' \\\\'
        print(u'\\hline')
        print(text)

        # print(u'\\hline')
        # text = u'Average'
        # for tech in self.techniques:
        # 	avgAP = avgTP = 0.0
        # 	count = 0
        # 	for group in S.groups:
        # 		count += len(S.projects[group])
        # 		avgAP += sum(APresults[group][project][tech] for project in S.projects[group])
        # 		avgTP += sum(TPresults[group][project][tech] for project in S.projects[group])
        # 	text += u' & {:.4f} & {:.4f}'.format(avgAP / count, avgTP/count)
        # text += u" \\\\"
        # print(text)
        pass
示例#14
0
    def compare_single_results(self, _basepath):
        '''
		for Table 1 : single results
		:param _basepath:
		:return:
		'''
        def get_averages(_itemType):
            results = {}
            for tData in ['Old', 'New_Single']:
                filepath = os.path.join(_basepath,
                                        u'%s_%s.txt' % (tData, _itemType))
                titles, data = self.load_results_items(filepath, ['str'] * 3 +
                                                       ['float'] * 6)
                for group in data:
                    if group not in results: results[group] = {}
                    for project in data[group]:
                        CNTs = dict(zip(titles, CNTdata[group][project]))
                        results[group][project] = self.get_technique_averages(
                            data[group][project], CNTs)
            return results

        techinques, CNTdata = self.load_results(
            os.path.join(_basepath, u'BugCNT.txt'), ['str'] * 2 + ['int'] * 6)

        APresults = get_averages('AP')
        TPresults = get_averages('TP')

        S = Subjects()

        # make MAP values for New Subjects
        print(u'\n\n')
        print(u'Technique Mann-Whitney U Test p-values')
        print(u'\t' + u'\t\t'.join(self.techniques))
        print(
            u'Subject\tMAP\tMRR\tMAP\tMRR\tMAP\tMRR\tMAP\tMRR\tMAP\tMRR\tMAP\tMRR'
        )
        print(u"\\hline")
        print(u"\\multicolumn{13}{c}{\\bf New subjects} \\\\")
        print(u"\\hline")
        for group in S.groups:
            for project in S.projects[group]:
                text = u'%s' % project
                APmax = self.get_max_technique(APresults[group][project],
                                               self.techniques)
                TPmax = self.get_max_technique(TPresults[group][project],
                                               self.techniques)

                for tech in self.techniques:
                    text += self.make_max_text(APresults[group][project][tech],
                                               APmax == tech, u'blue!25')
                    text += self.make_max_text(TPresults[group][project][tech],
                                               TPmax == tech, u'green!25')
                text += u' \\\\'
                print(text)

        # make average information
        avgAPs = dict(zip(self.techniques, [0] * len(self.techniques)))
        avgTPs = dict(zip(self.techniques, [0] * len(self.techniques)))
        for tech in self.techniques:
            count = 0
            for group in S.groups:
                count += len(S.projects[group])
                avgAPs[tech] += sum(APresults[group][project][tech]
                                    for project in S.projects[group])
                avgTPs[tech] += sum(TPresults[group][project][tech]
                                    for project in S.projects[group])
            avgAPs[tech] /= count
            avgTPs[tech] /= count

        text = u'Average'
        APmax = self.get_max_technique(avgAPs, self.techniques)
        TPmax = self.get_max_technique(avgTPs, self.techniques)
        for tech in self.techniques:
            text += self.make_max_text(avgAPs[tech], APmax == tech, u'blue!25')
            text += self.make_max_text(avgTPs[tech], TPmax == tech,
                                       u'green!25')
        text += u' \\\\'
        print(u'\\hline')
        print(text)

        # make MAP values for OLD Subjects
        print(u"\\hline")
        print(u"\\multicolumn{13}{c}{\\bf Old subjects} \\\\")
        print(u"\\hline")
        group = u'Previous'
        projects = [u'AspectJ', u'ZXing', u'PDE', u'JDT', u'SWT']
        for project in projects:
            text = u'%s' % project
            APmax = self.get_max_technique(APresults[group][project],
                                           self.techniques)
            TPmax = self.get_max_technique(TPresults[group][project],
                                           self.techniques)

            for tech in self.techniques:
                text += self.make_max_text(APresults[group][project][tech],
                                           APmax == tech, u'blue!25')
                text += self.make_max_text(TPresults[group][project][tech],
                                           TPmax == tech, u'green!25')
            text += u' \\\\'
            print(text)

        # make average information
        avgAPs = {}
        avgTPs = {}
        for tech in self.techniques:
            avgAPs[tech] = sum(APresults[group][project][tech]
                               for project in projects) / len(projects)
            avgTPs[tech] = sum(TPresults[group][project][tech]
                               for project in projects) / len(projects)

        text = u'Average'
        APmax = self.get_max_technique(avgAPs, self.techniques)
        TPmax = self.get_max_technique(avgTPs, self.techniques)
        for tech in self.techniques:
            text += self.make_max_text(avgAPs[tech], APmax == tech, u'blue!25')
            text += self.make_max_text(avgTPs[tech], TPmax == tech,
                                       u'green!25')
        text += u' \\\\'
        print(u'\\hline')
        print(text)

        pass
示例#15
0
 def __init__(self):
     self.S = Subjects()
     pass