Skip to content
Snippets Groups Projects
Commit 10b896c1 authored by Fays Jérémie's avatar Fays Jérémie
Browse files

Upload New File

parent 9d4a00ec
No related branches found
No related tags found
No related merge requests found
# Script analysing results from Simian (http://www.harukizaemon.com/simian/) xml file output
# in order to detect plagiarism between two projects. It will filter Simian results and remove
# all duplicated blocks that concern only one project.
#
# File structure needs to be the following :
#
# simianBaseDir
# bin/
# simianApp
# CODE/
# (this script)
# projectName/
# project1/ (contains source code of project 1)
# project2/ (contains source code of project 2)
# ... (could contain other projects)
#
# ----------------------------------------------------------------------
# Result : writes a file named projectName+'-simian-filtered.xml' in the CODE/ directory
# This file contains only duplicated code from one project to another (all duplicated code within a project is removed)
#
import subprocess
simianBaseDir='/simianDir'
simianApp="simian-2.4.0.jar"
projectName='projectNameDir'
callArgument='java -jar '+simianBaseDir+'/bin/'+simianApp+' -formatter=xml:'+projectName+'-simian.xml "'+simianBaseDir+'/CODE/Predetector/**/*.*"'
#print callArgument
retcode = subprocess.Popen(callArgument, shell=True)
#function that returns the main subdirectory from the 'projectName' directory
def getSubProject(filePath):
subProjectPath = filePath.split(projectName, 1)
subProjectName = subProjectPath[1].split('/',2)
return subProjectName[1]
import xml.etree.ElementTree as ET
tree = ET.parse(simianBaseDir+"/CODE/"+projectName+'-simian.xml')
root = tree.getroot()
for set in root[0].findall('set'):
duplicateCount=0
#stores the first subproject name from the set, in order to compare with others
sourceFile=set[0].get('sourceFile')
firstDir=getSubProject(sourceFile)
for block in set.iter('block'):
if getSubProject(block.get('sourceFile')) != firstDir:
duplicateCount=duplicateCount+1
if not duplicateCount:
root[0].remove(set)
tree.write(simianBaseDir+"/CODE/"+projectName+'-simian-filtered.xml')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment