Ejemplo n.º 1
0
 // Computes the score by comparing the ratio of matches found to fingerprint size
 private void computeScore() {
   int max1 = 0;
   int max2 = 0;
   for (int i = 0; i < project1.getSourceFileCount(); i++) {
     max1 += project1.getSourceFile(i).fingerprint.size();
   }
   for (int i = 0; i < project2.getSourceFileCount(); i++) {
     max2 += project2.getSourceFile(i).fingerprint.size();
   }
   score1 = (double) usedHashes1.size() / max1;
   score2 = (double) usedHashes2.size() / max2;
 }
Ejemplo n.º 2
0
  private void checkPlagiarism() {
    for (int k = 0; k < project1.getSourceFileCount(); k++) {
      for (int l = 0; l < project2.getSourceFileCount(); l++) {
        boolean isPlagiarised = false;

        SourceFile src1 = project1.getSourceFile(k);
        SourceFile src2 = project2.getSourceFile(l);
        SourceFilePlagiarism sourceFilePlagiarism = new SourceFilePlagiarism(src1, src2);

        for (int m = 0; m < src1.fingerprint.size(); m++) {
          for (int n = 0; n < src2.fingerprint.size(); n++) {
            if (src1.fingerprint.get(m).value == src2.fingerprint.get(n).value) {
              isPlagiarised = true;
              this.isPlagiarised = true;

              int[] pos1 = new int[2];
              Hash hash1 = src1.fingerprint.get(m);
              pos1[0] = src1.fingerprint.get(m).startPos;
              pos1[1] = src1.fingerprint.get(m).endPos;

              int[] pos2 = new int[2];
              Hash hash2 = src2.fingerprint.get(n);
              pos2[0] = src2.fingerprint.get(n).startPos;
              pos2[1] = src2.fingerprint.get(n).endPos;

              sourceFilePlagiarism.addPlagiarisedScore(hash1, hash2, this);
            }
          }
        }
        if (isPlagiarised) {
          plagiarisedSourceFiles.add(sourceFilePlagiarism);
          sourceFilePlagiarism.computeScore();
        }
      }
    }
    computeScore();
  }