Explorar o código

Remove the unsupported features clustering and comparison strategy selection.

Timur Sağlam %!s(int64=5) %!d(string=hai) anos
pai
achega
d1d2dceb25

+ 1 - 1
jplag.frontend-utils/src/main/java/jplag/Structure.java

@@ -10,7 +10,7 @@ import java.io.ObjectOutputStream;
 
 
 //import java.util.zip.*;
 //import java.util.zip.*;
 
 
-/** The tokenlist */
+/** The tokenlist */ // TODO PB: The name 'Structure' is very generic and should be changed to something more descriptive.
 public class Structure implements TokenConstants {
 public class Structure implements TokenConstants {
 	public Token[] tokens = new Token[0];
 	public Token[] tokens = new Token[0];
 	Table table = null;
 	Table table = null;

+ 1 - 74
jplag/src/main/java/jplag/JPlag.java

@@ -18,16 +18,10 @@ import java.util.Properties;
 import java.util.Vector;
 import java.util.Vector;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
-import jplag.clustering.Clusters;
-import jplag.clustering.SimilarityMatrix;
-import jplag.options.ClusterType;
 import jplag.options.LanguageOption;
 import jplag.options.LanguageOption;
 import jplag.strategy.ComparisonMode;
 import jplag.strategy.ComparisonMode;
 import jplag.strategy.ComparisonStrategy;
 import jplag.strategy.ComparisonStrategy;
-import jplag.strategy.ExternalComparisonStrategy;
 import jplag.strategy.NormalComparisonStrategy;
 import jplag.strategy.NormalComparisonStrategy;
-import jplag.strategy.RevisionComparisonStrategy;
-import jplag.strategy.SpecialComparisonStrategy;
 import jplagUtils.PropertiesLoader;
 import jplagUtils.PropertiesLoader;
 
 
 /**
 /**
@@ -53,19 +47,11 @@ public class JPlag implements ProgramI {
      */
      */
     public Vector<String> errorVector = new Vector<>();
     public Vector<String> errorVector = new Vector<>();
 
 
-    /**
-     * Used Objects of anothers jplag.Classes, they muss be just one time instantiate TODO PB: What?
-     */
-    public Clusters clusters = null;
 
 
     private int errors = 0;
     private int errors = 0;
 
 
-    private String invalidSubmissionNames = null;
-
     public Language language;
     public Language language;
 
 
-    public SimilarityMatrix similarity = null;
-
     /**
     /**
      * The base code directory is considered a separate submission.
      * The base code directory is considered a separate submission.
      */
      */
@@ -114,20 +100,10 @@ public class JPlag implements ProgramI {
 
 
     public void initializeComparisonStrategy() throws ExitException {
     public void initializeComparisonStrategy() throws ExitException {
         ComparisonMode mode = options.getComparisonMode();
         ComparisonMode mode = options.getComparisonMode();
-
-        switch (mode) {
+        switch (mode) { // TODO TS: Currently only one comparison strategy supported
         case NORMAL:
         case NORMAL:
             this.comparisonStrategy = new NormalComparisonStrategy(options, gSTiling);
             this.comparisonStrategy = new NormalComparisonStrategy(options, gSTiling);
             return;
             return;
-        case REVISION:
-            this.comparisonStrategy = new RevisionComparisonStrategy(options, gSTiling);
-            return;
-        case SPECIAL:
-            this.comparisonStrategy = new SpecialComparisonStrategy(options, gSTiling);
-            return;
-        case EXTERNAL:
-            this.comparisonStrategy = new ExternalComparisonStrategy(options, gSTiling);
-            return;
         default:
         default:
             throw new ExitException("Illegal comparison mode: " + options.getComparisonMode());
             throw new ExitException("Illegal comparison mode: " + options.getComparisonMode());
         }
         }
@@ -225,11 +201,6 @@ public class JPlag implements ProgramI {
         // errorVector is not needed anymore
         // errorVector is not needed anymore
         errorVector = null;
         errorVector = null;
 
 
-        if (options.getClusterType() != ClusterType.NONE) {
-            clusters = new Clusters(this);
-            similarity = new SimilarityMatrix(submissions.size());
-        }
-
         System.gc();
         System.gc();
 
 
         JPlagResult result = comparisonStrategy.compareSubmissions(submissions, baseCodeSubmission);
         JPlagResult result = comparisonStrategy.compareSubmissions(submissions, baseCodeSubmission);
@@ -383,10 +354,6 @@ public class JPlag implements ProgramI {
         long msec = System.currentTimeMillis();
         long msec = System.currentTimeMillis();
         Iterator<Submission> iter = submissions.iterator();
         Iterator<Submission> iter = submissions.iterator();
 
 
-        if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
-            makeTempDir();
-        }
-
         int invalid = 0;
         int invalid = 0;
         while (iter.hasNext()) {
         while (iter.hasNext()) {
             boolean ok;
             boolean ok;
@@ -409,19 +376,6 @@ public class JPlag implements ProgramI {
                 removed = true;
                 removed = true;
             }
             }
 
 
-            if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
-                if (subm.tokenList != null) {
-                    this.gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), false);
-                    subm.tokenList.save(new File("temp", subm.submissionFile.getName() + subm.name));
-                    subm.tokenList = null;
-                }
-            }
-
-            if (options.getComparisonMode() != ComparisonMode.EXTERNAL && subm.tokenList == null) {
-                invalidSubmissionNames = (invalidSubmissionNames == null) ? subm.name : invalidSubmissionNames + " - " + subm.name;
-                iter.remove();
-            }
-
             if (ok && !removed) {
             if (ok && !removed) {
                 print(null, "OK\n");
                 print(null, "OK\n");
             } else {
             } else {
@@ -460,9 +414,6 @@ public class JPlag implements ProgramI {
         print("----- Parsing basecode submission: " + subm.name + "\n", null);
         print("----- Parsing basecode submission: " + subm.name + "\n", null);
 
 
         // lets go:
         // lets go:
-        if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
-            makeTempDir();
-        }
 
 
         if (!subm.parse()) {
         if (!subm.parse()) {
             printErrors();
             printErrors();
@@ -477,14 +428,6 @@ public class JPlag implements ProgramI {
             gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), true);
             gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), true);
         }
         }
 
 
-        if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
-            if (subm.tokenList != null) {
-                gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), false);
-                subm.tokenList.save(new File("temp", subm.submissionFile.getName() + subm.name));
-                subm.tokenList = null;
-            }
-        }
-
         print("\nBasecode submission parsed!\n", null);
         print("\nBasecode submission parsed!\n", null);
 
 
         long time = System.currentTimeMillis() - msec;
         long time = System.currentTimeMillis() - msec;
@@ -525,22 +468,6 @@ public class JPlag implements ProgramI {
         }
         }
     }
     }
 
 
-    private void makeTempDir() throws ExitException {
-        print(null, "Creating temporary dir.\n");
-        File f = new File("temp");
-        if (!f.exists()) {
-            if (!f.mkdirs()) {
-                throw new jplag.ExitException("Cannot create temporary directory!");
-            }
-        }
-        if (!f.isDirectory()) {
-            throw new ExitException("'temp' is not a directory!");
-        }
-        if (!f.canWrite()) {
-            throw new ExitException("Cannot write directory: 'temp'");
-        }
-    }
-
     private void myWrite(String str) {
     private void myWrite(String str) {
         if (writer != null) {
         if (writer != null) {
             try {
             try {

+ 1 - 15
jplag/src/main/java/jplag/JPlagOptions.java

@@ -2,7 +2,6 @@ package jplag;
 
 
 import static jplag.strategy.ComparisonMode.NORMAL;
 import static jplag.strategy.ComparisonMode.NORMAL;
 
 
-import jplag.options.ClusterType;
 import jplag.options.LanguageOption;
 import jplag.options.LanguageOption;
 import jplag.options.SimilarityMetric;
 import jplag.options.SimilarityMetric;
 import jplag.options.Verbosity;
 import jplag.options.Verbosity;
@@ -46,11 +45,6 @@ public class JPlagOptions {
      */
      */
     private int numberOfSubmissionsToCompareTo = 0; // 0 = deactivated
     private int numberOfSubmissionsToCompareTo = 0; // 0 = deactivated
 
 
-    /**
-     * Clustering option.
-     */
-    private ClusterType clusterType;
-
     /**
     /**
      * Determines which strategy to use for the comparison of submissions.
      * Determines which strategy to use for the comparison of submissions.
      */
      */
@@ -155,11 +149,7 @@ public class JPlagOptions {
     public boolean hasMinTokenMatch() {
     public boolean hasMinTokenMatch() {
         return this.minTokenMatch != null;
         return this.minTokenMatch != null;
     }
     }
-
-    public ClusterType getClusterType() {
-        return clusterType;
-    }
-
+    
     public ComparisonMode getComparisonMode() {
     public ComparisonMode getComparisonMode() {
         return comparisonMode;
         return comparisonMode;
     }
     }
@@ -226,10 +216,6 @@ public class JPlagOptions {
         this.numberOfSubmissionsToCompareTo = numberOfSubmissionsToCompareTo;
         this.numberOfSubmissionsToCompareTo = numberOfSubmissionsToCompareTo;
     }
     }
 
 
-    public void setClusterType(ClusterType clusterType) {
-        this.clusterType = clusterType;
-    }
-
     public void setComparisonMode(ComparisonMode comparisonMode) {
     public void setComparisonMode(ComparisonMode comparisonMode) {
         this.comparisonMode = comparisonMode;
         this.comparisonMode = comparisonMode;
     }
     }

+ 0 - 2
jplag/src/main/java/jplag/Submission.java

@@ -38,8 +38,6 @@ public class Submission implements Comparable<Submission> {
 
 
     /**
     /**
      * List of tokens that have been parsed from the files this submission consists of.
      * List of tokens that have been parsed from the files this submission consists of.
-     * <p>
-     * TODO PB: The name 'Structure' is very generic and should be changed to something more descriptive.
      */
      */
     public Structure tokenList;
     public Structure tokenList;
 
 

+ 0 - 188
jplag/src/main/java/jplag/clustering/Cluster.java

@@ -1,188 +0,0 @@
-package jplag.clustering;
-
-public class Cluster implements Comparable<Cluster> {
-
-    private float similarity; // similarity threshold for this cluster
-
-    private int submissionNr = -1;
-    // !=-1 -> this cluster consists of one document only
-
-    private Cluster left, right;
-
-    private int[] allSubmissions = null;
-    private Clusters clusters;// Warum habe ich nicht instanziert? ist es schon woanders instanziert? Emeric
-    public int x = -1, y = -1; // Coordinates for the dendrogram
-
-    public Cluster(int submissionNr, Clusters clusters) {
-        this.clusters = clusters;
-        this.submissionNr = submissionNr;
-        left = right = null;
-        similarity = 100;
-    }
-
-    // changed by Emeric Kwemou now, a cluster muss belong to a specific Objekt
-    // of Type Clusters ->Clusters object added in Constructor
-
-    public Cluster(Cluster left, Cluster right, float similarity, Clusters clusters) {
-        this.clusters = clusters;
-        this.submissionNr = -1;
-        this.left = left;
-        this.right = right;
-        this.similarity = similarity;
-
-        calculateAllSubmissions();
-    }
-
-    public int size() {
-        return (submissionNr == -1 ? allSubmissions.length : 1);
-    }
-
-    public int getSubmissionAt(int i) {
-        return (submissionNr == -1 ? allSubmissions[i] : submissionNr);
-    }
-
-    public float getSimilarity() {
-        return similarity;
-    }
-
-    public Cluster getLeft() {
-        return left;
-    }
-
-    public Cluster getRight() {
-        return right;
-    }
-
-    private void calculateAllSubmissions() {
-        if (submissionNr == -1) {
-            int rSize = right.size();
-            int lSize = left.size();
-            allSubmissions = new int[lSize + rSize];
-
-            if (left.allSubmissions != null) {
-                System.arraycopy(left.allSubmissions, 0, allSubmissions, 0, lSize);
-            } else {
-                allSubmissions[0] = left.submissionNr;
-            }
-
-            if (right.allSubmissions != null) {
-                System.arraycopy(right.allSubmissions, 0, allSubmissions, lSize, rSize);
-            } else {
-                allSubmissions[lSize] = right.submissionNr;
-            }
-
-            // int i, li, ri;
-            // i = ri = li = 0;
-
-            // insert-sort
-            // while (i<lSize+rSize) {
-            // boolean takeLeft = true;
-            // if (li<lSize && ri<rSize)
-            // takeLeft = (left.getSubmissionAt(li) <
-            // right.getSubmissionAt(ri));
-            // else
-            // takeLeft = (li < lSize);
-
-            // if (takeLeft)
-            // allSubmissions[i++] = left.getSubmissionAt(li++);
-            // else
-            // allSubmissions[i++] = right.getSubmissionAt(ri++);
-            // }
-        } else {
-            allSubmissions = null;
-        }
-    }
-
-    // for MIN clustering
-    public float maxSimilarity(Cluster other, SimilarityMatrix simMatrix) {
-        int sizeThis = size();
-        int sizeOther = other.size();
-        float maxSim = -1;
-
-        for (int a = 0; a < sizeThis; a++) {
-            for (int b = 0; b < sizeOther; b++) {
-                float sim = simMatrix.getSimilarity(this.getSubmissionAt(a), other.getSubmissionAt(b));
-                if (sim > maxSim) {
-                    maxSim = sim;
-                }
-            }
-        }
-
-        return maxSim;
-    }
-
-    // for MAX clustering
-    public float minSimilarity(Cluster other, SimilarityMatrix simMatrix) {
-        int sizeThis = size();
-        int sizeOther = other.size();
-        float minSim = 100;
-
-        for (int a = 0; a < sizeThis; a++) {
-            for (int b = 0; b < sizeOther; b++) {
-                float sim = simMatrix.getSimilarity(this.getSubmissionAt(a), other.getSubmissionAt(b));
-                if (sim < minSim) {
-                    minSim = sim;
-                }
-            }
-        }
-
-        return minSim;
-    }
-
-    // for AVR clustering
-    public float avrSimilarity(Cluster other, SimilarityMatrix simMatrix) {
-        int sizeThis = size();
-        int sizeOther = other.size();
-        float summedSim = 0;
-
-        for (int a = 0; a < sizeThis; a++) {
-            for (int b = 0; b < sizeOther; b++) {
-                summedSim += simMatrix.getSimilarity(this.getSubmissionAt(a), other.getSubmissionAt(b));
-            }
-        }
-        return summedSim / (sizeThis * sizeOther);
-    }
-
-    @Override
-    public String toString() {
-        String text = (submissionNr == -1 ? "Similarity: " + similarity + ":" : "Submission:");
-        for (int i = 0; i < size(); i++) {
-            text += " " + clusters.submissions.elementAt(getSubmissionAt(i)).name;
-        }
-        text += "\n\n";
-        if (left != null) {
-            text += left.toString();
-        }
-        if (right != null) {
-            text += right.toString();
-        }
-        return text;
-    }
-
-    @Override
-    public int compareTo(Cluster cluster2) {
-        if (equals(cluster2)) {
-            return 0;
-        }
-
-        int s1Size = size();
-        int s2Size = cluster2.size();
-
-        if (s1Size != s2Size) {
-            return (s1Size < s2Size ? +1 : -1);
-        }
-
-        int size = 0;
-        for (int i = 0; i < s1Size; i++) {
-            String name1 = clusters.submissions.elementAt(getSubmissionAt(i)).name;
-            String name2 = clusters.submissions.elementAt(cluster2.getSubmissionAt(i)).name;
-            if (name1.compareTo(name2) != 0) {
-                return name1.compareTo(name2);
-            }
-            size += name1.length();
-            size -= name2.length();
-        }
-
-        return (size >= 0 ? 1 : -1);
-    }
-}

+ 0 - 92
jplag/src/main/java/jplag/clustering/Clusters.java

@@ -1,92 +0,0 @@
-package jplag.clustering;
-
-import java.util.ArrayList;
-import java.util.Vector;
-
-import jplag.JPlag;
-import jplag.Submission;
-import jplag.options.ClusterType;
-
-/**
- * This class calculates, based on the similarity matrix, the hierarchical clustering of the documents, using MIN, MAX
- * and AVR methods.
- */
-public class Clusters {
-
-    public Vector<Submission> submissions;
-    public float maxMergeValue = 0;
-    private JPlag program;
-
-    public Clusters(JPlag program) {
-        this.program = program;
-    }
-
-    public Cluster calculateClustering(Vector<Submission> submissions) {
-        this.submissions = submissions;
-        Cluster clusters = null;
-
-        switch (this.program.getOptions().getClusterType()) {
-        case MAX:
-        case MIN:
-        case AVG:
-            clusters = minMaxAvrClustering();
-            break;
-        default:
-        }
-
-        return clusters;
-    }
-
-    /**
-     * Min clustering...
-     */
-    public Cluster minMaxAvrClustering() {
-        int nrOfSubmissions = submissions.size();
-        boolean minClustering = (this.program.getOptions().getClusterType() == ClusterType.MIN);
-        boolean maxClustering = (this.program.getOptions().getClusterType() == ClusterType.MAX);
-        SimilarityMatrix simMatrix = this.program.similarity;
-
-        ArrayList<Cluster> clusters = new ArrayList<Cluster>(submissions.size());
-        for (int i = 0; i < nrOfSubmissions; i++) {
-            clusters.add(new Cluster(i, this));
-        }
-
-        while (clusters.size() > 1) {
-            int indexA = -1, indexB = -1;
-            float maxSim = -1;
-            int nrOfClusters = clusters.size();
-
-            // find similarity
-            for (int a = 0; a < (nrOfClusters - 1); a++) {
-                Cluster cluster = clusters.get(a);
-                for (int b = a + 1; b < nrOfClusters; b++) {
-                    float sim;
-                    if (minClustering) {
-                        sim = cluster.maxSimilarity(clusters.get(b), simMatrix);
-                    } else if (maxClustering) {
-                        sim = cluster.minSimilarity(clusters.get(b), simMatrix);
-                    } else {
-                        sim = cluster.avrSimilarity(clusters.get(b), simMatrix);
-                    }
-                    if (sim > maxSim) {
-                        maxSim = sim;
-                        indexA = a;
-                        indexB = b;
-                    }
-                }
-            }
-
-            if (maxSim > maxMergeValue) {
-                maxMergeValue = maxSim;
-            }
-
-            // now merge these clusters
-            Cluster clusterA = clusters.get(indexA);
-            Cluster clusterB = clusters.get(indexB);
-            clusters.remove(clusterA);
-            clusters.remove(clusterB);
-            clusters.add(new Cluster(clusterA, clusterB, maxSim, this));
-        }
-        return clusters.get(0);
-    }
-}

+ 0 - 67
jplag/src/main/java/jplag/clustering/SimilarityMatrix.java

@@ -1,67 +0,0 @@
-package jplag.clustering;
-
-public class SimilarityMatrix {
-
-    private int size;
-    private float[] matrix;
-    // private float maximum = 0;
-
-    /**
-     * The parameter is the number of submissions.
-     */
-    public SimilarityMatrix(int size) {
-        this.size = size;
-        matrix = new float[size * (size + 1) / 2];
-    }
-
-    public int size() {
-        return size;
-    }
-
-    public void setSimilarity(int a, int b, float sim) {
-        int tmp;
-        if (a >= size || b >= size) {
-            throw new ArrayIndexOutOfBoundsException();
-        }
-        if (a > b) {
-            tmp = a;
-            a = b;
-            b = tmp;
-        }
-        matrix[a + (b * (b - 1) / 2)] = sim;
-
-        // if (sim > maximum)
-        // maximum = sim;
-    }
-
-    // public float getMaximum() { return maximum; }
-
-    public float getSimilarity(int a, int b) {
-        int tmp;
-        if (a >= size || b >= size) {
-            throw new ArrayIndexOutOfBoundsException();
-        }
-        if (a > b) {
-            tmp = a;
-            a = b;
-            b = tmp;
-        }
-        return matrix[a + (b * (b - 1) / 2)];
-    }
-
-    @Override
-    public String toString() {
-        String tmp = "";
-        for (int a = 0; a < size; a++) {
-            for (int b = a + 1; b < size; b++) {
-                int length = tmp.length();
-                tmp += (int) getSimilarity(a, b);
-                while (tmp.length() < length + 3) {
-                    tmp += " ";
-                }
-            }
-            tmp += "\n";
-        }
-        return tmp;
-    }
-}

+ 0 - 8
jplag/src/main/java/jplag/options/ClusterType.java

@@ -1,8 +0,0 @@
-package jplag.options;
-
-public enum ClusterType {
-    NONE,
-    MIN,
-    MAX,
-    AVG
-}

+ 0 - 107
jplag/src/main/java/jplag/reporting/Report.java

@@ -122,11 +122,6 @@ public class Report {
 
 
         writeIndex();
         writeIndex();
 
 
-        // TODO TS: Cluster currently not supported
-        // if (result.getOptions().getClusterType() != ClusterType.NONE) {
-        // writeClusters(clustering);
-        // }
-
         copyStaticFiles();
         copyStaticFiles();
 
 
         writeMatches(result.getComparisons());
         writeMatches(result.getComparisons());
@@ -445,108 +440,6 @@ public class Report {
         htmlFile.println("</TABLE>");
         htmlFile.println("</TABLE>");
     }
     }
 
 
-    // --------------------------------------------------------------------------
-    // ==========================================================================
-    // --------------------------------------------------------------------------
-
-    // TODO:
-    // /* this function copies all submissions into the result directory */
-    // private int copySubmissions() throws jplag.ExitException {
-    // int bytes = 0;
-    // for (Iterator<Submission> i = program.clusters.neededSubmissions.iterator(); i.hasNext(); ) {
-    // Submission sub = i.next();
-    // int index = this.program.clusters.submissions.indexOf(sub);
-    //
-    // HTMLFile f = createHTMLFile(reportDir, "submission" + index + ".html");
-    // writeHTMLHeader(f, sub.name);
-    // f.println("<BODY BGCOLOR=\"#ffffff\">");
-    //
-    // String[] files = sub.files;
-    // String text[][] = sub.readFiles(files);
-    //
-    // for (int j = 0; j < files.length; j++) {
-    // f.println("<HR>\n<H3><CENTER>" + files[j] + "</CENTER></H3><HR>");
-    // if (this.language.isPreformated()) {
-    // f.println("<PRE>");
-    // }
-    // for (int k = 0; k < text[j].length; k++) {
-    // f.print(text[j][k]);
-    // if (!this.language.isPreformated()) {
-    // f.println("<BR>");
-    // } else {
-    // f.println();
-    // }
-    // }
-    // if (language.isPreformated()) {
-    // f.println("</PRE>");
-    // }
-    // }
-    //
-    // f.println("</BODY>\n</HTML>");
-    // f.close();
-    // bytes += f.bytesWritten();
-    // }
-    // return bytes;
-    // }
-
-    // TODO TS: Cluster currently not supported
-    // private int writeClusters(Cluster clustering) throws jplag.ExitException {
-    // int bytes = 0;
-    //
-    // HTMLFile f = createHTMLFile("cluster.html");
-    // writeHTMLHeader(f, msg.getString("Report.Clustering_Results"));
-    // String clustertype = msg.getString("Report.Type") + ": " + program.clusters.getType();
-    // f.println("<BODY>\n<H2>" + msg.getString("Report.Clustering_Results") + " (" + clustertype
-    // + ")</H2>");
-    // f.println("<H3><A HREF=\"dendro.html\">" + msg.getString("Report.Dendrogram") + "</A></H3>");
-    // bytes += this.program.clusters.makeDendrograms(reportDir, clustering);
-    //
-    // if (this.program.get_threshold() != null) {
-    // for (int i = 0; i < this.program.get_threshold().length; i++) {
-    // float threshold = this.program.get_threshold()[i];
-    // String clustertitle = TagParser
-    // .parse(msg.getString("Report.Clusters_for_Xpercent_treshold"),
-    // new String[]{threshold + ""});
-    // f.println("<H3><A HREF=\"cluster" + threshold + ".html\">" + clustertitle + "</A></H3>");
-    // HTMLFile f2 = createHTMLFile(reportDir, "cluster" + threshold + ".html");
-    // writeHTMLHeader(f2, clustertitle);
-    // f2.println("<BODY>\n<H2>" + clustertitle + " (" + clustertype + ")</H2>");
-    // String text = program.clusters.printClusters(clustering, threshold, f2);
-    // f2.println("</BODY>\n</HTML>");
-    // f2.close();
-    // bytes += f2.bytesWritten();
-    // f.print(text);
-    // }
-    // } else {
-    // float increase = this.program.clusters.maxMergeValue / 10;
-    // if (increase < 5) {
-    // increase = 5;
-    // }
-    // for (float threshold = increase; threshold <= program.clusters.maxMergeValue;
-    // threshold += increase) {
-    // String clustertitle = TagParser
-    // .parse(msg.getString("Report.Clusters_for_Xpercent_treshold"),
-    // new String[]{threshold + ""});
-    // f.println(
-    // "<H3><A HREF=\"cluster" + (int) threshold + ".html\">" + clustertitle + "</A></H3>");
-    // HTMLFile f2 = createHTMLFile(reportDir, "cluster" + (int) threshold + ".html");
-    // writeHTMLHeader(f2, clustertitle);
-    // f2.println("<BODY>\n<H2>" + clustertitle + " (" + clustertype + ")</H2>");
-    // String text = program.clusters.printClusters(clustering, (int) threshold, f2);
-    // f2.println("</BODY>\n</HTML>");
-    // f2.close();
-    // bytes += f2.bytesWritten();
-    // f.print(text);
-    // }
-    // }
-    //
-    // f.println("</BODY>\n</HTML>");
-    // f.close();
-    //
-    // bytes += copySubmissions();
-    // return f.bytesWritten() + bytes;
-    // }
-
     // SUBMISSION - here it comes...
     // SUBMISSION - here it comes...
     private final String[] pics = {"forward.gif", "back.gif"};
     private final String[] pics = {"forward.gif", "back.gif"};
 
 

+ 1 - 4
jplag/src/main/java/jplag/strategy/ComparisonMode.java

@@ -4,8 +4,5 @@ package jplag.strategy;
  * The comparison mode determines which `ComparisonStrategy` is used to compare submissions.
  * The comparison mode determines which `ComparisonStrategy` is used to compare submissions.
  */
  */
 public enum ComparisonMode {
 public enum ComparisonMode {
-    NORMAL,
-    REVISION,
-    SPECIAL,
-    EXTERNAL
+    NORMAL // TODO TS: Currently only one comparison strategy supported
 }
 }

+ 0 - 346
jplag/src/main/java/jplag/strategy/ExternalComparisonStrategy.java

@@ -1,346 +0,0 @@
-package jplag.strategy;
-
-import java.io.File;
-import java.util.Vector;
-
-import jplag.GreedyStringTiling;
-import jplag.JPlagComparison;
-import jplag.JPlagOptions;
-import jplag.JPlagResult;
-import jplag.SortedVector;
-import jplag.Structure;
-import jplag.Submission;
-import jplag.clustering.Cluster;
-
-@SuppressWarnings("unused") // TODO TS: External comparison strategy currently not supported
-public class ExternalComparisonStrategy extends AbstractComparisonStrategy {
-
-    private final Runtime runtime = Runtime.getRuntime();
-
-    public ExternalComparisonStrategy(JPlagOptions options, GreedyStringTiling gSTiling) {
-        super(options, gSTiling);
-    }
-
-    /**
-     * This is the special external comparison routine
-     */
-    @Override
-    public JPlagResult compareSubmissions(Vector<Submission> submissions, Submission baseCodeSubmission) {
-        try {
-            int size = submissions.size();
-
-            // Result vector
-            SortedVector<JPlagComparison> avgmatches = new SortedVector<>(new JPlagComparison.AvgComparator());
-            SortedVector<JPlagComparison> maxmatches = new SortedVector<>(new JPlagComparison.MaxComparator());
-            int[] dist = new int[10];
-
-            // print("Comparing: " + size + " submissions\n", null);
-
-            long totalComparisons = (size * (size - 1)) / 2, count = 0, comparisons = 0;
-            int index;
-            JPlagComparison match;
-            Submission first, second;
-            long remain;
-            String totalTimeStr, remainTime;
-
-            // print("Checking memory size...\n", null);
-
-            // First try to load as many submissions as possible
-            index = fillMemory(submissions, 0, size);
-
-            long startTime;
-            long totalTime = 0;
-            int startA = 0;
-            int endA = index / 2;
-            int startB = endA + 1;
-            int endB = index;
-            int i, j;
-            // long progStart;
-
-            do {
-                // compare A to A
-                startTime = System.currentTimeMillis();
-                // print("Comparing block A (" + startA + "-" + endA + ") to block A\n", null);
-
-                for (i = startA; i <= endA; i++) {
-                    first = submissions.elementAt(i);
-
-                    if (first.tokenList == null) {
-                        count += (endA - i);
-                        continue;
-                    }
-
-                    for (j = (i + 1); j <= endA; j++) {
-                        second = submissions.elementAt(j);
-
-                        if (second.tokenList == null) {
-                            count++;
-                            continue;
-                        }
-
-                        match = this.gSTiling.compare(first, second);
-                        registerMatch(match, avgmatches, maxmatches, null, i, j);
-                        comparisons++;
-                        count++;
-                    }
-                }
-
-                // print("\n", null);
-                totalTime += System.currentTimeMillis() - startTime;
-
-                // Are we finished?
-                if (startA == startB) {
-                    break;
-                }
-
-                do {
-                    totalTimeStr = "" + ((totalTime / 3600000 > 0) ? (totalTime / 3600000) + " h " : "")
-                            + ((totalTime / 60000 > 0) ? ((totalTime / 60000) % 60) + " min " : "") + (totalTime / 1000 % 60) + " sec";
-
-                    if (comparisons != 0) {
-                        remain = totalTime * (totalComparisons - count) / comparisons;
-                    } else {
-                        remain = 0;
-                    }
-
-                    remainTime = "" + ((remain / 3600000 > 0) ? (remain / 3600000) + " h " : "")
-                            + ((remain / 60000 > 0) ? ((remain / 60000) % 60) + " min " : "") + (remain / 1000 % 60) + " sec";
-
-                    // print("Progress: " + (100 * count) / totalComparisons + "%\nTime used for comparisons: "
-                    // + totalTimeStr
-                    // + "\nRemaining time (estimate): " + remainTime + "\n", null);
-
-                    // compare A to B
-                    startTime = System.currentTimeMillis();
-                    // print("Comparing block A (" + startA + "-" + endA + ") to block B (" + startB + "-" + endB
-                    // + ")\n", null);
-
-                    for (i = startB; i <= endB; i++) {
-                        first = submissions.elementAt(i);
-
-                        if (first.tokenList == null) {
-                            count += (endA - startA + 1);
-                            continue;
-                        }
-
-                        for (j = startA; j <= endA; j++) {
-                            second = submissions.elementAt(j);
-
-                            if (second.tokenList == null) {
-                                count++;
-                                continue;
-                            }
-
-                            match = this.gSTiling.compare(first, second);
-                            registerMatch(match, avgmatches, maxmatches, null, i, j);
-                            comparisons++;
-                            count++;
-                        }
-
-                        first.tokenList = null; // remove B
-                    }
-
-                    // print("\n", null);
-                    totalTime += System.currentTimeMillis() - startTime;
-
-                    if (endB == size - 1) {
-                        totalTimeStr = "" + ((totalTime / 3600000 > 0) ? (totalTime / 3600000) + " h " : "")
-                                + ((totalTime / 60000 > 0) ? ((totalTime / 60000) % 60) + " min " : "") + (totalTime / 1000 % 60) + " sec";
-                        remain = totalTime * (totalComparisons - count) / comparisons;
-                        remainTime = "" + ((remain / 3600000 > 0) ? (remain / 3600000) + " h " : "")
-                                + ((remain / 60000 > 0) ? ((remain / 60000) % 60) + " min " : "") + (remain / 1000 % 60) + " sec";
-
-                        // print("Progress: " + (100 * count) / totalComparisons + "%\nTime used for comparisons: "
-                        // + totalTimeStr
-                        // + "\nRemaining time (estimate): " + remainTime + "\n", null);
-                        break;
-                    }
-
-                    runtime.runFinalization();
-                    runtime.gc();
-                    Thread.yield();
-
-                    // Try to find the next B
-                    // print("Finding next B\n", null);
-
-                    index = fillMemory(submissions, endB + 1, size);
-
-                    startB = endB + 1;
-                    endB = index;
-
-                } while (true);
-
-                // Remove A
-                for (i = startA; i <= endA; i++) {
-                    submissions.elementAt(i).tokenList = null;
-                }
-
-                runtime.runFinalization();
-                runtime.gc();
-                Thread.yield();
-
-                // print("Find next A.\n", null);
-
-                // First try to load as many submissions as possible
-
-                index = fillMemory(submissions, endA + 1, size);
-
-                if (index != size - 1) {
-                    startA = endA + 1;
-                    endA = startA + (index - startA + 1) / 2;
-                    startB = endA + 1;
-                    endB = index;
-                } else {
-                    startA = startB; // last block
-                    endA = endB = index;
-                }
-            } while (true);
-
-            totalTime += System.currentTimeMillis() - startTime;
-            totalTimeStr = "" + ((totalTime / 3600000 > 0) ? (totalTime / 3600000) + " h " : "")
-                    + ((totalTime / 60000 > 0) ? ((totalTime / 60000) % 60000) + " min " : "") + (totalTime / 1000 % 60) + " sec";
-
-            // print("Total comparison time: " + totalTimeStr + "\nComparisons: " + count + "/" + comparisons
-            // + "/" + totalComparisons + "\n",
-            // null);
-
-            // free remaining memory
-            for (i = startA; i <= endA; i++) {
-                submissions.elementAt(i).tokenList = null;
-            }
-
-            runtime.runFinalization();
-            runtime.gc();
-            Thread.yield();
-
-            Cluster cluster = null;
-
-            // TODO TS: Cluster currently not supported
-            // if (options.getClusterType() == ClusterType.NONE) {
-            // cluster = this.clusters.calculateClustering(submissions);
-            // }
-
-            // TODO TS: External comparison strategy currently not supported
-            // Deprecated:
-            // writeResults(dist, avgmatches, maxmatches, null, cluster);
-
-            // TODO TS: External comparison strategy currently not supported
-            return new JPlagResult();
-        } catch (OutOfMemoryError e) {
-            e.printStackTrace();
-            return new JPlagResult();
-        }
-    }
-
-    private int fillMemory(Vector<Submission> submissions, int from, int size) {
-        Submission sub = null;
-        int index = from;
-
-        runtime.runFinalization();
-        runtime.gc();
-        Thread.yield();
-        long freeBefore = runtime.freeMemory();
-        try {
-            for (; index < size; index++) {
-                sub = submissions.elementAt(index);
-                sub.tokenList = new Structure();
-                if (!sub.tokenList.load(new File("temp", sub.submissionFile.getName() + sub.name))) {
-                    sub.tokenList = null;
-                }
-            }
-        } catch (java.lang.OutOfMemoryError e) {
-            sub.tokenList = null;
-            // print("Memory overflow after loading " + (index - from + 1) + " submissions.\n", null);
-        }
-        if (index >= size) {
-            index = size - 1;
-        }
-
-        if (freeBefore / runtime.freeMemory() <= 2) {
-            return index;
-        }
-        for (int i = (index - from) / 2; i > 0; i--) {
-            submissions.elementAt(index--).tokenList = null;
-        }
-        runtime.runFinalization();
-        runtime.gc();
-        Thread.yield();
-
-        // make sure we freed half of the "available" memory.
-        long free;
-        while (freeBefore / (free = runtime.freeMemory()) > 2) {
-            submissions.elementAt(index--).tokenList = null;
-            runtime.runFinalization();
-            runtime.gc();
-            Thread.yield();
-        }
-
-        // print(free / 1024 / 1024 + "MByte freed. Current index: " + index + "\n", null);
-
-        return index;
-    }
-
-    private void registerMatch(JPlagComparison match, SortedVector<JPlagComparison> avgMatches, SortedVector<JPlagComparison> maxMatches,
-            SortedVector<JPlagComparison> minMatches, int a, int b) {
-        float avgPercent = match.percent();
-        float maxPercent = match.percentMaxAB();
-        float minPercent = match.percentMinAB();
-
-        if (!options.isStorePercent()) {
-            if ((avgMatches.size() < options.getStoreMatches() || avgPercent > avgMatches.lastElement().percent()) && avgPercent > 0) {
-                avgMatches.insert(match);
-
-                if (avgMatches.size() > options.getStoreMatches()) {
-                    avgMatches.removeElementAt(options.getStoreMatches());
-                }
-            }
-
-            if (maxMatches != null && (maxMatches.size() < options.getStoreMatches() || maxPercent > maxMatches.lastElement().percent())
-                    && maxPercent > 0) {
-                maxMatches.insert(match);
-
-                if (maxMatches.size() > options.getStoreMatches()) {
-                    maxMatches.removeElementAt(options.getStoreMatches());
-                }
-            }
-
-            if (minMatches != null && (minMatches.size() < options.getStoreMatches() || minPercent > minMatches.lastElement().percent())
-                    && minPercent > 0) {
-                minMatches.insert(match);
-
-                if (minMatches.size() > options.getStoreMatches()) {
-                    minMatches.removeElementAt(options.getStoreMatches());
-                }
-            }
-        } else { // store_percent
-            if (avgPercent > options.getStoreMatches()) {
-                avgMatches.insert(match);
-
-                if (avgMatches.size() > JPlagOptions.MAX_RESULT_PAIRS) {
-                    avgMatches.removeElementAt(JPlagOptions.MAX_RESULT_PAIRS);
-                }
-            }
-
-            if (maxMatches != null && maxPercent > options.getStoreMatches()) {
-                maxMatches.insert(match);
-
-                if (maxMatches.size() > JPlagOptions.MAX_RESULT_PAIRS) {
-                    maxMatches.removeElementAt(JPlagOptions.MAX_RESULT_PAIRS);
-                }
-            }
-
-            if (minMatches != null && minPercent > options.getStoreMatches()) {
-                minMatches.insert(match);
-
-                if (minMatches.size() > JPlagOptions.MAX_RESULT_PAIRS) {
-                    minMatches.removeElementAt(JPlagOptions.MAX_RESULT_PAIRS);
-                }
-            }
-        }
-
-        // TODO TS: Cluster currently not supported
-        // if (options.getClusterType() != ClusterType.NONE) {
-        // similarity.setSimilarity(a, b, avgPercent);
-        // }
-    }
-}

+ 0 - 7
jplag/src/main/java/jplag/strategy/NormalComparisonStrategy.java

@@ -60,13 +60,6 @@ public class NormalComparisonStrategy extends AbstractComparisonStrategy {
 
 
         long durationInMillis = System.currentTimeMillis() - timeBeforeStartInMillis;
         long durationInMillis = System.currentTimeMillis() - timeBeforeStartInMillis;
 
 
-        // TODO TS: Cluster currently not supported
-        // Cluster cluster = null;
-        //
-        // if (options.getClusterType() != ClusterType.NONE) {
-        // cluster = this.clusters.calculateClustering(submissions);
-        // }
-
         return new JPlagResult(comparisons, durationInMillis, numberOfSubmissions, options);
         return new JPlagResult(comparisons, durationInMillis, numberOfSubmissions, options);
     }
     }
 
 

+ 0 - 79
jplag/src/main/java/jplag/strategy/RevisionComparisonStrategy.java

@@ -1,79 +0,0 @@
-package jplag.strategy;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Vector;
-
-import jplag.GreedyStringTiling;
-import jplag.JPlagComparison;
-import jplag.JPlagOptions;
-import jplag.JPlagResult;
-import jplag.Submission;
-
-public class RevisionComparisonStrategy extends AbstractComparisonStrategy {
-
-    public RevisionComparisonStrategy(JPlagOptions options, GreedyStringTiling gSTiling) {
-        super(options, gSTiling);
-    }
-
-    @Override
-    public JPlagResult compareSubmissions(Vector<Submission> submissions, Submission baseCodeSubmission) {
-        if (baseCodeSubmission != null) {
-            compareSubmissionsToBaseCode(submissions, baseCodeSubmission);
-        }
-
-        long timeBeforeStartInMillis = System.currentTimeMillis();
-        int numberOfSubmissions = submissions.size();
-        Submission first, second;
-        JPlagComparison comparison;
-
-        List<JPlagComparison> comparisons = new ArrayList<>();
-
-        s1loop: for (int i = 0; i < numberOfSubmissions - 1;) {
-            first = submissions.elementAt(i);
-
-            if (first.tokenList == null) {
-                continue;
-            }
-
-            // Find next valid submission
-            int j = i;
-
-            do {
-                j++;
-
-                if (j >= numberOfSubmissions) {
-                    break s1loop; // no more comparison pairs available
-                }
-
-                second = submissions.elementAt(j);
-            } while (second.tokenList == null);
-
-            comparison = this.gSTiling.compare(first, second);
-
-            System.out.println("Comparing " + first.name + "-" + second.name + ": " + comparison.percent());
-
-            if (baseCodeSubmission != null) {
-                comparison.bcMatchesA = baseCodeMatches.get(comparison.firstSubmission.name);
-                comparison.bcMatchesB = baseCodeMatches.get(comparison.secondSubmission.name);
-            }
-
-            if (isAboveSimilarityThreshold(comparison)) {
-                comparisons.add(comparison);
-            }
-
-            i = j;
-        }
-
-        long durationInMillis = System.currentTimeMillis() - timeBeforeStartInMillis;
-
-        // TODO TS: Cluster currently not supported
-        // Cluster cluster = null;
-        //
-        // if (options.getClusterType() != ClusterType.NONE) {
-        // cluster = this.clusters.calculateClustering(submissions);
-        // }
-
-        return new JPlagResult(comparisons, durationInMillis, numberOfSubmissions, options);
-    }
-}

+ 0 - 93
jplag/src/main/java/jplag/strategy/SpecialComparisonStrategy.java

@@ -1,93 +0,0 @@
-package jplag.strategy;
-
-import java.io.File;
-import java.util.Vector;
-
-import jplag.GreedyStringTiling;
-import jplag.JPlagComparison;
-import jplag.JPlagOptions;
-import jplag.JPlagResult;
-import jplag.SortedVector;
-import jplag.Submission;
-
-@SuppressWarnings("unused") // TODO TS: Special comparison strategy currently not supported
-public class SpecialComparisonStrategy extends AbstractComparisonStrategy {
-
-    public SpecialComparisonStrategy(JPlagOptions options, GreedyStringTiling gSTiling) {
-        super(options, gSTiling);
-    }
-
-    /*
-     * Now the special comparison TODO PB: Previously, this comparison created a `Report.java` (removed) TODO PB: Check
-     * whether this comparison is now any different than the others after the report has been removed
-     */
-    @Override
-    public JPlagResult compareSubmissions(Vector<Submission> submissions, Submission baseCodeSubmission) {
-        File root = new File(options.getRootDirName());
-
-        int size = submissions.size();
-        int matchIndex = 0;
-
-        // TODO TS: Special comparison strategy currently not supported
-        // print("Comparing: ", countValidSubmissions() + " submissions");
-        // print("\n(Writing results at the same time.)\n", null);
-
-        int totalcomps = size * size;
-        int i, j, anz = 0, count = 0;
-        JPlagComparison match;
-        Submission first, second;
-        long msec = System.currentTimeMillis();
-
-        for (i = 0; i < (size - 1); i++) {
-            // Result vector
-            SortedVector<JPlagComparison> matches = new SortedVector<>(new JPlagComparison.AvgComparator());
-
-            first = submissions.elementAt(i);
-
-            if (first.tokenList == null) {
-                count += (size - 1);
-                continue;
-            }
-
-            for (j = 0; j < size; j++) {
-                second = submissions.elementAt(j);
-
-                if ((i == j) || (second.tokenList == null)) {
-                    count++;
-                    continue;
-                }
-
-                match = this.gSTiling.compare(first, second);
-                anz++;
-
-                float percent = match.percent();
-
-                if ((matches.size() < options.getNumberOfSubmissionsToCompareTo() || matches.size() == 0
-                        || match.moreThan(matches.lastElement().percent())) && match.moreThan(0)) {
-                    matches.insert(match);
-                    if (matches.size() > options.getNumberOfSubmissionsToCompareTo()) {
-                        matches.removeElementAt(options.getNumberOfSubmissionsToCompareTo());
-                    }
-                }
-
-                // TODO TS: Special comparison strategy currently not supported
-                // if (options.getClusterType() != ClusterType.NONE) {
-                // similarity.setSimilarity(i, j, percent);
-                // }
-
-                count++;
-            }
-        }
-
-        long time = System.currentTimeMillis() - msec;
-
-        // TODO TS: Special comparison strategy currently not supported
-        // print("\n", "Total time: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "")
-        // + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60)
-        // + " sec\n" + "Time per comparison: "
-        // + (time / anz) + " msec\n");
-
-        // TODO TS: Special comparison strategy currently not supported
-        return new JPlagResult();
-    }
-}