def resultToHtml(self, result, t1, t2): """Computes html texts for the given result and texts t1 and t2 in which all similarities are marked. returns a list [markedText1, markedText2] """ vis = PlagVisualizer() return vis.resultToHtml(result, t1, t2)
def dotplot(self, other):#, REQUEST=None): """Compare this assignment to another one. Using a dotplot. """ vis = PlagVisualizer() image = vis.stringsToDotplot(str(self.getFile()), str(other.getFile()), id1=self.pretty_title_or_id(), id2=other.pretty_title_or_id(), showIdNums=True) return image
def dotplot(self, other): #, REQUEST=None): """Compare this assignment to another one. Using a dotplot. """ vis = PlagVisualizer() image = vis.stringsToDotplot(str(self.getFile()), str(other.getFile()), id1=self.pretty_title_or_id(), id2=other.pretty_title_or_id(), showIdNums=True) return image
def diff2(self, other): """Compare this assignment to another one. """ checker = PlagChecker() result = checker.compare(str(self.getFile()), str(other.getFile()), self.pretty_title_or_id(), other.pretty_title_or_id()) vis = PlagVisualizer() strList = vis.resultToHtml(result, str(self.getFile()), str(other.getFile())) return strList
def createDotplot(self, assignment1, assignment2, REQUEST=None): """Creates a dotplot image for viewing purposes. """ vis = PlagVisualizer() image = vis.stringsToDotplot(str(assignment1),str(assignment2), id1="Id1",id2="Id2",showIdNums=True) imageData = StringIO() image.save(imageData, 'JPEG') if not REQUEST: REQUEST = self.REQUEST REQUEST.RESPONSE.setHeader('Content-Type', 'image/jpeg') return REQUEST.RESPONSE.write(imageData.getvalue())
def createDotplot2(self, assignment1, assignment2): """Creates a dotplot image for viewing purposes. """ vis = PlagVisualizer() image = vis.stringsToDotplot(str(assignment1.getFile()),str(assignment2.getFile()), id1=assignment1.pretty_title_or_id(),id2=assignment2.pretty_title_or_id(), showIdNums=True) imageData = StringIO() image.save(imageData, 'JPEG') id = "dotplotImg" if hasattr(self, id): self.manage_delObjects([id]) self.manage_addImage(id, imageData.getvalue(), content_type="image/jpeg") return id
def createDotplotFromLists(strList, idList, REQUEST): """Takes two lists - one for the texts and one containing the corresponding ids for each text and computes the Dotplot image and returns it. """ if not strList or not idList: REQUEST.RESPONSE.setHeader('Content-Type', 'text/html') msg = 'createDotplotDirectCompare has failed.'\ 'selectedResults: %s objects: %s assignments: &s'\ 'strList: %s idList: %s' % (str(selectedResults), str(objects), str(assignments), str(strList), str(idList)) return REQUEST.RESPONSE.write(msg) #compute image image = PlagVisualizer().stringListToDotplot(strList, idList=idList) imageData = StringIO() image.save(imageData, 'JPEG') REQUEST.RESPONSE.setHeader('Content-Type', 'image/jpeg') return REQUEST.RESPONSE.write(imageData.getvalue())
def createIntensityHeatmap(self): """Creates a torc using the given results. Showing the similarity relations between all suspected plagiarism pairs. """ #get REQUEST REQUEST = self.REQUEST #get PlagResults session = REQUEST.SESSION if session.has_key('results'): results = session['results'] if results == []: return None #compute image image = PlagVisualizer().resultsToIntensityHeatmap(results) imageData = StringIO() image.save(imageData, 'JPEG') if not REQUEST: REQUEST = self.REQUEST REQUEST.RESPONSE.setHeader('Content-Type', 'image/jpeg') return REQUEST.RESPONSE.write(imageData.getvalue())
def stringsToCPP(self, basefile=""): REQUEST = self.REQUEST #get Infos basefile = fromUTF8toISOEncoding(basefile) objects = self.objectValues() ensemble = [str(o.getFile()) for o in objects] for i in xrange(len(ensemble)): ensemble[i] = fromUTF8toISOEncoding(ensemble[i]) klength = 7 normName = "NORMAL" if not (basefile and ensemble and klength and normName): return None #compute image vis = PlagVisualizer() #TODO: categoriCal image = vis.stringsToCompositeCategoricalPatterngram(basefile, ensemble, klength, normName) imageData = StringIO() fmt = 'JPEG' image.save(imageData, fmt) if not REQUEST: REQUEST = self.REQUEST REQUEST.RESPONSE.setHeader('Content-Type', 'image/jpeg') return REQUEST.RESPONSE.write(imageData.getvalue())