Просмотр исходного кода

Added some comments for to important interfaces, minor alterations to TODO comments and names.

Timur Sağlam 5 лет назад
Родитель
Сommit
86277efd19

+ 19 - 17
jplag/src/main/java/jplag/JPlag.java

@@ -30,9 +30,8 @@ import jplag.strategy.RevisionComparisonStrategy;
 import jplag.strategy.SpecialComparisonStrategy;
 import jplagUtils.PropertiesLoader;
 
-/*
+/**
  * This class coordinates the whole program flow.
- * The revision history can be found on https://svn.ipd.kit.edu/trac/jplag/wiki/JPlag/History
  */
 public class JPlag implements ProgramI {
 
@@ -48,7 +47,7 @@ public class JPlag implements ProgramI {
   /**
    * This stores the name of the submission that is currently parsed.
    * <p>
-   * TODO: This should be moved to parseSubmissions(...)
+   * TODO PB: This should be moved to parseSubmissions(...)
    */
   public String currentSubmissionName = "<Unknown submission>";
 
@@ -58,7 +57,7 @@ public class JPlag implements ProgramI {
   public Vector<String> errorVector = new Vector<>();
 
   /**
-   * Used Objects of anothers jplag.Classes, they muss be just one time instantiate TODO: What?
+   * Used Objects of anothers jplag.Classes, they muss be just one time instantiate TODO PB: What?
    */
   public Clusters clusters = null;
 
@@ -88,7 +87,7 @@ public class JPlag implements ProgramI {
   /**
    * Contains the comparison logic.
    */
-  protected GSTiling gSTiling = new GSTiling(this);
+  protected GreedyStringTiling gSTiling = new GreedyStringTiling(this);
 
   /**
    * JPlag configuration options.
@@ -100,9 +99,13 @@ public class JPlag implements ProgramI {
    */
   private FileWriter writer = null;
 
+  /**
+   * Creates and initializes a JPlag instance, parameterized by a set of options.
+   * @param options determines the parameterization.
+   * @throws ExitException if the initialization fails.
+   */
   public JPlag(JPlagOptions options) throws ExitException {
     this.options = options;
-
     this.initialize();
   }
 
@@ -137,18 +140,15 @@ public class JPlag implements ProgramI {
     LanguageOption languageOption = this.options.getLanguageOption();
 
     try {
-      Class<?> languageClass = Class.forName(languageOption.getClassPath());
-      Constructor<?>[] languageConstructors = languageClass.getDeclaredConstructors();
-
-      // TODO: Verify that only one constructor exists
-      Constructor<?> constructor = languageConstructors[0];
+      Constructor<?> constructor = Class.forName(languageOption.getClassPath()).getConstructor(ProgramI.class);
       Object[] constructorParams = {this};
 
       Language language = (Language) constructor.newInstance(constructorParams);
 
       this.language = language;
       this.options.setLanguage(language);
-    } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
+    } catch (NoSuchMethodException | SecurityException | ClassNotFoundException | InstantiationException | IllegalAccessException
+            | IllegalArgumentException | InvocationTargetException e) {
       e.printStackTrace();
 
       throw new ExitException("Language instantiation failed", ExitException.BAD_LANGUAGE_ERROR);
@@ -206,7 +206,9 @@ public class JPlag implements ProgramI {
   }
 
   /**
-   * Main procedure
+   * Main procedure, executes the comparison of source code submissions.
+   * @return the results of the comparison, specifically the submissions whose similarity exceeds a set threshold.
+   * @throws ExitException if the JPlag exits preemptively.
    */
   public JPlagResult run() throws ExitException {
     File rootDir = new File(options.getRootDirName());
@@ -258,7 +260,7 @@ public class JPlag implements ProgramI {
   }
 
   /**
-   * TODO: Find a better way to separate parseSubmissions(...) and parseBaseCodeSubmission(...)
+   * TODO PB: Find a better way to separate parseSubmissions(...) and parseBaseCodeSubmission(...)
    */
   public void parseAllSubmissions(Vector<Submission> submissions, Submission baseCodeSubmission)
       throws ExitException {
@@ -441,7 +443,7 @@ public class JPlag implements ProgramI {
 
       if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
         if (subm.tokenList != null) {
-          this.gSTiling.create_hashes(subm.tokenList, options.getMinTokenMatch(), false);
+          this.gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), false);
           subm.tokenList.save(new File("temp", subm.submissionFile.getName() + subm.name));
           subm.tokenList = null;
         }
@@ -509,12 +511,12 @@ public class JPlag implements ProgramI {
     }
 
     if (options.hasBaseCode()) {
-      gSTiling.create_hashes(subm.tokenList, options.getMinTokenMatch(), true);
+      gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), true);
     }
 
     if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
       if (subm.tokenList != null) {
-        gSTiling.create_hashes(subm.tokenList, options.getMinTokenMatch(), false);
+        gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), false);
         subm.tokenList.save(new File("temp", subm.submissionFile.getName() + subm.name));
         subm.tokenList = null;
       }

+ 2 - 3
jplag/src/main/java/jplag/JPlagBaseCodeComparison.java

@@ -2,12 +2,11 @@ package jplag;
 
 /**
  * @author Michael Cocheteau
- *
  */
 public class JPlagBaseCodeComparison extends JPlagComparison {
 	
-	public JPlagBaseCodeComparison(Submission subA, Submission subB) {
-		super(subA, subB);
+	public JPlagBaseCodeComparison(Submission firstSubmission, Submission secondSubmission) {
+		super(firstSubmission, secondSubmission);
 	}
 
 }

+ 18 - 18
jplag/src/main/java/jplag/JPlagComparison.java

@@ -10,17 +10,17 @@ import java.util.List;
  */
 public class JPlagComparison implements Comparator<JPlagComparison> {
 
-  public Submission subA;
-  public Submission subB;
+  public Submission firstSubmission;
+  public Submission secondSubmission;
 
   public JPlagBaseCodeComparison bcMatchesA = null;
   public JPlagBaseCodeComparison bcMatchesB = null;
 
   public List<Match> matches = new ArrayList<>();
 
-  public JPlagComparison(Submission subA, Submission subB) {
-    this.subA = subA;
-    this.subB = subB;
+  public JPlagComparison(Submission firstSubmission, Submission secondSubmission) {
+    this.firstSubmission = firstSubmission;
+    this.secondSubmission = secondSubmission;
   }
 
   public final void addMatch(int startA, int startB, int length) {
@@ -127,11 +127,11 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
   public final float percent() {
     float sa, sb;
     if (bcMatchesB != null && bcMatchesA != null) {
-      sa = subA.getNumberOfTokens() - subA.files.size() - bcMatchesA.getNumberOfMatchedTokens();
-      sb = subB.getNumberOfTokens() - subB.files.size() - bcMatchesB.getNumberOfMatchedTokens();
+      sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size() - bcMatchesA.getNumberOfMatchedTokens();
+      sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size() - bcMatchesB.getNumberOfMatchedTokens();
     } else {
-      sa = subA.getNumberOfTokens() - subA.files.size();
-      sb = subB.getNumberOfTokens() - subB.files.size();
+      sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
+      sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
     }
     return (200 * (float) getNumberOfMatchedTokens()) / (sa + sb);
   }
@@ -140,9 +140,9 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
     int divisor;
     if (bcMatchesA != null) {
       divisor =
-          subA.getNumberOfTokens() - subA.files.size() - bcMatchesA.getNumberOfMatchedTokens();
+          firstSubmission.getNumberOfTokens() - firstSubmission.files.size() - bcMatchesA.getNumberOfMatchedTokens();
     } else {
-      divisor = subA.getNumberOfTokens() - subA.files.size();
+      divisor = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
     }
     return (divisor == 0 ? 0f : (getNumberOfMatchedTokens() * 100 / (float) divisor));
   }
@@ -151,9 +151,9 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
     int divisor;
     if (bcMatchesB != null) {
       divisor =
-          subB.getNumberOfTokens() - subB.files.size() - bcMatchesB.getNumberOfMatchedTokens();
+          secondSubmission.getNumberOfTokens() - secondSubmission.files.size() - bcMatchesB.getNumberOfMatchedTokens();
     } else {
-      divisor = subB.getNumberOfTokens() - subB.files.size();
+      divisor = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
     }
     return (divisor == 0 ? 0f : (getNumberOfMatchedTokens() * 100 / (float) divisor));
   }
@@ -189,12 +189,12 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
   }
 
   public final float percentBasecodeA() {
-    float sa = subA.getNumberOfTokens() - subA.files.size();
+    float sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
     return bcMatchesA.getNumberOfMatchedTokens() * 100 / sa;
   }
 
   public final float percentBasecodeB() {
-    float sb = subB.getNumberOfTokens() - subB.files.size();
+    float sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
     return bcMatchesB.getNumberOfMatchedTokens() * 100 / sb;
   }
 
@@ -217,7 +217,7 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
       return new String[]{};
     }
 
-    Token[] tokens = (j == 0 ? subA : subB).tokenList.tokens;
+    Token[] tokens = (j == 0 ? firstSubmission : secondSubmission).tokenList.tokens;
     int i, h, starti, starth, count = 1;
 
     o1:
@@ -268,7 +268,7 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
   /* This method returns the name of all files that are represented by
    * at least one token. */
   public final String[] allFiles(int sub) {
-    Structure struct = (sub == 0 ? subA : subB).tokenList;
+    Structure struct = (sub == 0 ? firstSubmission : secondSubmission).tokenList;
     int count = 1;
     for (int i = 1; i < struct.size(); i++) {
       if (!struct.tokens[i].file.equals(struct.tokens[i - 1].file)) {
@@ -322,7 +322,7 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
   }
 
   public String toString() {
-    return subA.name + " <-> " + subB.name;
+    return firstSubmission.name + " <-> " + secondSubmission.name;
   }
 
   public static class AvgComparator implements Comparator<JPlagComparison> {

+ 2 - 2
jplag/src/main/java/jplag/JPlagOptions.java

@@ -38,7 +38,7 @@ public class JPlagOptions {
   private boolean storePercent = false;
 
   /**
-   * TODO: Decide what to do with this.
+   * TODO PB: Decide what to do with this.
    * <p>
    * Note: Previously, this option had two effects:
    * <ol>
@@ -75,7 +75,7 @@ public class JPlagOptions {
   private float similarityThreshold = 0;
 
   /**
-   * TODO: Not happy with the name yet.
+   * TODO PB: Not happy with the name yet.
    */
   private SimilarityMetric similarityMetric = SimilarityMetric.AVG;
 

+ 87 - 97
jplag/src/main/java/jplag/JPlagResult.java

@@ -1,104 +1,94 @@
 package jplag;
 
-import java.util.ArrayList;
 import java.util.List;
 
+/**
+ * Encapsulates the results of a comparison of a set of source code submissions.
+ */
 public class JPlagResult {
 
-  /**
-   * List of detected comparisons whose similarity was about the specified threshold.
-   */
-  private List<JPlagComparison> comparisons;
-
-  /**
-   * Duration of the JPlag run in milliseconds.
-   */
-  private long durationInMillis;
-
-  /**
-   * Total number of submissions that have been compared.
-   */
-  private int numberOfSubmissions;
-
-  /**
-   * Options for the plagiarism detection run.
-   */
-  private JPlagOptions options;
-
-  /**
-   * 10-element array representing the similarity distribution of the detected matches.
-   * <p>
-   * Each entry represents the absolute frequency of matches whose similarity lies within the
-   * respective interval.
-   * <p>
-   * Intervals:
-   * <p>
-   * 0: [0% - 10%), 1: [10% - 20%), 2: [20% - 30%), ..., 9: [90% - 100%]
-   */
-  private int[] similarityDistribution = null;
-
-  public JPlagResult() {
-  }
-
-  public JPlagResult(
-      List<JPlagComparison> comparisons,
-      long durationInMillis,
-      int numberOfSubmissions,
-      JPlagOptions options
-  ) {
-    this.comparisons = comparisons;
-    this.durationInMillis = durationInMillis;
-    this.numberOfSubmissions = numberOfSubmissions;
-    this.options = options;
-
-    this.similarityDistribution = calculateSimilarityDistribution(comparisons);
-  }
-
-  /**
-   * Note: Before, comparisons with a similarity below the given threshold were also included in the
-   * similarity matrix.
-   */
-  private int[] calculateSimilarityDistribution(List<JPlagComparison> comparisons) {
-    int[] similarityDistribution = new int[10];
-
-    comparisons.stream()
-        .map(JPlagComparison::percent)
-        .map(percent -> percent / 10)
-        .map(Float::intValue)
-        .map(index -> index == 10 ? 9 : index)
-        .forEach(index -> similarityDistribution[index]++);
-
-    return similarityDistribution;
-  }
-
-  public List<JPlagComparison> getComparisons() {
-    return comparisons;
-  }
-
-  public long getDuration() {
-    return durationInMillis;
-  }
-
-  public JPlagOptions getOptions() {
-    return options;
-  }
-
-  public int getNumberOfSubmissions() {
-    return numberOfSubmissions;
-  }
-
-  public int[] getSimilarityDistribution() {
-    return similarityDistribution;
-  }
-
-  @Override
-  public String toString() {
-    return String.format(
-        "JPlagResult { comparisons: %d, duration: %d ms, language: %s, submissions: %d }",
-        getComparisons().size(),
-        getDuration(),
-        getOptions().getLanguageOption(),
-        getNumberOfSubmissions()
-    );
-  }
+    /**
+     * List of detected comparisons whose similarity was about the specified threshold.
+     */
+    private List<JPlagComparison> comparisons;
+
+    /**
+     * Duration of the JPlag run in milliseconds.
+     */
+    private long durationInMillis;
+
+    /**
+     * Total number of submissions that have been compared.
+     */
+    private int numberOfSubmissions;
+
+    /**
+     * Options for the plagiarism detection run.
+     */
+    private JPlagOptions options;
+
+    /**
+     * 10-element array representing the similarity distribution of the detected matches.
+     * <p>
+     * Each entry represents the absolute frequency of matches whose similarity lies within the respective interval.
+     * <p>
+     * Intervals:
+     * <p>
+     * 0: [0% - 10%), 1: [10% - 20%), 2: [20% - 30%), ..., 9: [90% - 100%]
+     */
+    private int[] similarityDistribution = null;
+
+    /**
+     * Creates empty results.
+     */
+    public JPlagResult() {
+        // No results available.
+    }
+
+    public JPlagResult(List<JPlagComparison> comparisons, long durationInMillis, int numberOfSubmissions, JPlagOptions options) {
+        this.comparisons = comparisons;
+        this.durationInMillis = durationInMillis;
+        this.numberOfSubmissions = numberOfSubmissions;
+        this.options = options;
+
+        this.similarityDistribution = calculateSimilarityDistribution(comparisons);
+    }
+
+    /**
+     * Note: Before, comparisons with a similarity below the given threshold were also included in the similarity matrix.
+     */
+    private int[] calculateSimilarityDistribution(List<JPlagComparison> comparisons) {
+        int[] similarityDistribution = new int[10];
+
+        comparisons.stream().map(JPlagComparison::percent).map(percent -> percent / 10).map(Float::intValue).map(index -> index == 10 ? 9 : index)
+                .forEach(index -> similarityDistribution[index]++);
+
+        return similarityDistribution;
+    }
+
+    public List<JPlagComparison> getComparisons() {
+        return comparisons;
+    }
+
+    public long getDuration() {
+        return durationInMillis;
+    }
+
+    public JPlagOptions getOptions() {
+        return options;
+    }
+
+    public int getNumberOfSubmissions() {
+        return numberOfSubmissions;
+    }
+
+    public int[] getSimilarityDistribution() {
+        return similarityDistribution;
+    }
+
+    @Override
+    public String toString() {
+        return String.format("JPlagResult { comparisons: %d, duration: %d ms, language: %s, submissions: %d }", getComparisons().size(),
+                getDuration(), getOptions().getLanguageOption(), getNumberOfSubmissions());
+    }
 }

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

@@ -39,7 +39,7 @@ public class Submission implements Comparable<Submission> {
   /**
    * List of tokens that have been parsed from the files this submission consists of.
    * <p>
-   * TODO: The name 'Structure' is very generic and should be changed to something more
+   * TODO PB: The name 'Structure' is very generic and should be changed to something more
    * descriptive.
    */
   public Structure tokenList;
@@ -229,7 +229,7 @@ public class Submission implements Comparable<Submission> {
         result[i] = buffer;
         fis.close();
       } catch (FileNotFoundException e) {
-        // TODO: Should an ExitException be thrown here?
+        // TODO PB: Should an ExitException be thrown here?
         System.out.println("File not found: " + ((new File(submissionFile, files[i])).toString()));
       } catch (IOException e) {
         throw new jplag.ExitException(

+ 18 - 29
jplag/src/main/java/jplag/reporting/Report.java

@@ -125,7 +125,7 @@ public class Report {
 
     writeIndex();
 
-    // TODO:
+    // TODO TS: Cluster currently not supported
     // if (result.getOptions().getClusterType() != ClusterType.NONE) {
     //   writeClusters(clustering);
     // }
@@ -155,17 +155,6 @@ public class Report {
     file.println("</HEAD>");
   }
 
-  private void writeHTMLHeaderWithScript(HTMLFile file, String title) {
-    file.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
-    file.println("<HTML>\n<HEAD>\n <TITLE>" + title + "</TITLE>");
-    file.println("<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
-    file.println("  <script type=\"text/javascript\">\n  <!--");
-    file.println("   function ZweiFrames(URL1,F1,URL2,F2)\n   {");
-    file.println("    parent.frames[F1].location.href=URL1;");
-    file.println("    parent.frames[F2].location.href=URL2;\n   }\n  //-->");
-    file.println("  </script>\n</HEAD>");
-  }
-
   /**
    * Write the index.html file.
    */
@@ -317,8 +306,8 @@ public class Report {
     htmlFile.println("<TABLE CELLPADDING=3 CELLSPACING=2>");
 
     for (JPlagComparison comparison : comparisons) {
-      String submissionNameA = comparison.subA.name;
-      String submissionNameB = comparison.subB.name;
+      String submissionNameA = comparison.firstSubmission.name;
+      String submissionNameB = comparison.secondSubmission.name;
 
       htmlFile.print(
           "<TR><TD BGCOLOR=" + color(comparison.percentA(), 128, 192, 128, 192, 255, 255)
@@ -351,8 +340,8 @@ public class Report {
       writer = new FileWriter(csvFile);
 
       for (JPlagComparison comparison : comparisons) {
-        String submissionNameA = comparison.subA.name;
-        String submissionNameB = comparison.subB.name;
+        String submissionNameA = comparison.firstSubmission.name;
+        String submissionNameB = comparison.secondSubmission.name;
 
         writer.write(getComparisonIndex(comparison) + ";");
         writer.write(submissionNameA + ";");
@@ -390,7 +379,7 @@ public class Report {
         htmlFile,
         TagParser.parse(
             msg.getString("Report.Matches_for_X1_AND_X2"),
-            new String[]{comparison.subA.name, comparison.subB.name}
+            new String[]{comparison.firstSubmission.name, comparison.secondSubmission.name}
         )
     );
 
@@ -403,7 +392,7 @@ public class Report {
     htmlFile.println(
         TagParser.parse(
             msg.getString("Report.Matches_for_X1_AND_X2"),
-            new String[]{comparison.subA.name, comparison.subB.name}
+            new String[]{comparison.firstSubmission.name, comparison.secondSubmission.name}
         )
     );
     htmlFile.println("      </h3>");
@@ -454,14 +443,14 @@ public class Report {
    */
   private void reportComparison(HTMLFile htmlFile, JPlagComparison comparison, int index) {
     Match match;
-    Token[] tokensA = comparison.subA.tokenList.tokens;
-    Token[] tokensB = comparison.subB.tokenList.tokens;
+    Token[] tokensA = comparison.firstSubmission.tokenList.tokens;
+    Token[] tokensB = comparison.secondSubmission.tokenList.tokens;
     // sort();
 
     htmlFile.println("<TABLE BORDER=\"1\" CELLSPACING=\"0\" BGCOLOR=\"#d0d0d0\">");
     htmlFile
-        .println("<TR><TH><TH>" + comparison.subA.name + " (" + comparison.percentA() + "%)<TH>" +
-            comparison.subB.name + " (" + comparison.percentB() + "%)<TH>" + msg
+        .println("<TR><TH><TH>" + comparison.firstSubmission.name + " (" + comparison.percentA() + "%)<TH>" +
+            comparison.secondSubmission.name + " (" + comparison.percentB() + "%)<TH>" + msg
             .getString("AllMatches.Tokens"));
 
     for (int i = 0; i < comparison.matches.size(); i++) {
@@ -557,7 +546,7 @@ public class Report {
 //    return bytes;
 //  }
 
-//  TODO:
+//  TODO TS: Cluster currently not supported
 //  private int writeClusters(Cluster clustering) throws jplag.ExitException {
 //    int bytes = 0;
 //
@@ -624,12 +613,12 @@ public class Report {
    */
   private void writeNormalSubmission(HTMLFile f, int i, JPlagComparison comparison, int j)
       throws ExitException {
-    Submission sub = (j == 0 ? comparison.subA : comparison.subB);
+    Submission sub = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission);
     String[] files = comparison.files(j);
 
     String[][] text = sub.readFiles(files);
 
-    Token[] tokens = (j == 0 ? comparison.subA : comparison.subB).tokenList.tokens;
+    Token[] tokens = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission).tokenList.tokens;
     Match currentMatch;
     String hilf;
     int h;
@@ -741,10 +730,10 @@ public class Report {
    */
   private void writeIndexedSubmission(HTMLFile f, int i, JPlagComparison comparison, int j)
       throws ExitException {
-    Submission sub = (j == 0 ? comparison.subA : comparison.subB);
+    Submission sub = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission);
     String[] files = comparison.files(j);
     char[][] text = sub.readFilesChar(files);
-    Token[] tokens = (j == 0 ? comparison.subA : comparison.subB).tokenList.tokens;
+    Token[] tokens = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission).tokenList.tokens;
 
     // get index array with matches sorted in ascending order.
     int[] perm = comparison.sort_permutation(j);
@@ -817,10 +806,10 @@ public class Report {
    */
   private int writeImprovedSubmission(HTMLFile f, int i, JPlagComparison comparison, int j)
       throws jplag.ExitException {
-    Submission sub = (j == 0 ? comparison.subA : comparison.subB);
+    Submission sub = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission);
     String[] files = comparison.files(j);
     String[][] text = sub.readFiles(files);
-    Token[] tokens = (j == 0 ? comparison.subA : comparison.subB).tokenList.tokens;
+    Token[] tokens = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission).tokenList.tokens;
 
     // Markup list:
     Comparator<MarkupText> comp = (mo1, mo2) -> {

+ 2 - 2
jplag/src/main/java/jplag/strategy/NormalComparisonStrategy.java

@@ -47,8 +47,8 @@ public class NormalComparisonStrategy extends AbstractComparisonStrategy {
                 System.out.println("Comparing " + first.name + "-" + second.name + ": " + comparison.percent());
 
                 if (baseCodeSubmission != null) {
-                    comparison.bcMatchesA = baseCodeMatches.get(comparison.subA.name);
-                    comparison.bcMatchesB = baseCodeMatches.get(comparison.subB.name);
+                    comparison.bcMatchesA = baseCodeMatches.get(comparison.firstSubmission.name);
+                    comparison.bcMatchesB = baseCodeMatches.get(comparison.secondSubmission.name);
                 }
 
                 if (isAboveSimilarityThreshold(comparison)) {

+ 2 - 2
jplag/src/main/java/jplag/strategy/RevisionComparisonStrategy.java

@@ -53,8 +53,8 @@ public class RevisionComparisonStrategy extends AbstractComparisonStrategy {
             System.out.println("Comparing " + first.name + "-" + second.name + ": " + comparison.percent());
 
             if (baseCodeSubmission != null) {
-                comparison.bcMatchesA = baseCodeMatches.get(comparison.subA.name);
-                comparison.bcMatchesB = baseCodeMatches.get(comparison.subB.name);
+                comparison.bcMatchesA = baseCodeMatches.get(comparison.firstSubmission.name);
+                comparison.bcMatchesB = baseCodeMatches.get(comparison.secondSubmission.name);
             }
 
             if (isAboveSimilarityThreshold(comparison)) {