Simon Ding 4 лет назад
Родитель
Сommit
42e49591b4

+ 0 - 15
jplag/src/main/java/de/jplag/JPlagComparison.java

@@ -206,21 +206,6 @@ public class JPlagComparison implements Comparator<JPlagComparison> { // FIXME T
         return ((int) (similarity() * ROUNDING_FACTOR)) / (float) ROUNDING_FACTOR;
         return ((int) (similarity() * ROUNDING_FACTOR)) / (float) ROUNDING_FACTOR;
     }
     }
 
 
-    /**
-     * @param submission Either the first of second submission of this comparison.
-     * 
-     * @return Number of non EOF tokens int the submission, excluding base code matches.
-     */
-    public final int getNumberOfCountingTokens(Submission submission) {
-        int numberOfTokens = submission.getNumberOfTokens() - submission.getFiles().size();
-        if (submission == firstSubmission && firstBaseCodeMatches != null) {
-            numberOfTokens -= firstBaseCodeMatches.getNumberOfMatchedTokens();
-        } else if (submission == secondSubmission && secondBaseCodeMatches != null) {
-            numberOfTokens -= secondBaseCodeMatches.getNumberOfMatchedTokens();
-        }
-        return numberOfTokens;
-    }
-
     /**
     /**
      * @return Similarity of the first submission to the basecode in percent rounded down to the nearest tenth.
      * @return Similarity of the first submission to the basecode in percent rounded down to the nearest tenth.
      */
      */

+ 8 - 8
jplag/src/main/java/de/jplag/clustering/algorithm/BFGS.java

@@ -89,7 +89,7 @@ import static java.lang.Math.sqrt;
  * @author Haifeng Li
  * @author Haifeng Li
  */
  */
 public class BFGS {
 public class BFGS {
-    private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BFGS.class);
+    //private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BFGS.class);
     /** A number close to zero, between machine epsilon and its square root. */
     /** A number close to zero, between machine epsilon and its square root. */
     private static final double EPSILON = Double.valueOf(System.getProperty("smile.bfgs.epsilon", "1E-10"));
     private static final double EPSILON = Double.valueOf(System.getProperty("smile.bfgs.epsilon", "1E-10"));
     /** The convergence criterion on function value. */
     /** The convergence criterion on function value. */
@@ -345,7 +345,7 @@ public class BFGS {
 
 
             for (double xi : x) {
             for (double xi : x) {
                 if (Double.isNaN(xi) || Double.isInfinite(xi)) {
                 if (Double.isNaN(xi) || Double.isInfinite(xi)) {
-                    logger.warn("L-BFGS-B: bad x produced by line search, return previous good x");
+                    //logger.warn("L-BFGS-B: bad x produced by line search, return previous good x");
                     System.arraycopy(x_old, 0, x, 0, n);
                     System.arraycopy(x_old, 0, x, 0, n);
                     return f_old;
                     return f_old;
                 }
                 }
@@ -354,18 +354,18 @@ public class BFGS {
             // STEP 5: compute gradient update current guess and function information
             // STEP 5: compute gradient update current guess and function information
             f = func.g(x, g);
             f = func.g(x, g);
             if (Double.isNaN(f) || Double.isInfinite(f)) {
             if (Double.isNaN(f) || Double.isInfinite(f)) {
-                logger.warn("L-BFGS-B: bad f(x) produced by line search, return previous good x");
+                //logger.warn("L-BFGS-B: bad f(x) produced by line search, return previous good x");
                 System.arraycopy(x_old, 0, x, 0, n);
                 System.arraycopy(x_old, 0, x, 0, n);
                 return f_old;
                 return f_old;
             }
             }
 
 
             if (gnorm(x, g, l, u) < gtol) {
             if (gnorm(x, g, l, u) < gtol) {
-                logger.info(String.format("L-BFGS-B converges on gradient after %d iterations: %.5f", iter, f));
+                //logger.info(String.format("L-BFGS-B converges on gradient after %d iterations: %.5f", iter, f));
                 return f;
                 return f;
             }
             }
 
 
             if (iter % 100 == 0) {
             if (iter % 100 == 0) {
-                logger.info(String.format("L-BFGS-B: the function value after %3d iterations: %.5f", iter, f));
+                //logger.info(String.format("L-BFGS-B: the function value after %3d iterations: %.5f", iter, f));
             }
             }
 
 
             // prepare for next iteration
             // prepare for next iteration
@@ -432,15 +432,15 @@ public class BFGS {
                 M = M.inverse();
                 M = M.inverse();
             }
             }
 
 
-            logger.debug("L-BFGS-B iteration {} moves from {} to {} where f(x) = {}", iter, Arrays.toString(x_old), Arrays.toString(x), f);
+            //logger.debug("L-BFGS-B iteration {} moves from {} to {} where f(x) = {}", iter, Arrays.toString(x_old), Arrays.toString(x), f);
 
 
             if (abs(f_old - f) < TOLF) {
             if (abs(f_old - f) < TOLF) {
-                logger.info(String.format("L-BFGS-B converges on f(x) after %d iterations: %.5f", iter, f));
+                //logger.info(String.format("L-BFGS-B converges on f(x) after %d iterations: %.5f", iter, f));
                 return f;
                 return f;
             }
             }
         }
         }
 
 
-        logger.warn(String.format("L-BFGS-B reaches maximum %d iterations: %.5f", maxIter, f));
+        //logger.warn(String.format("L-BFGS-B reaches maximum %d iterations: %.5f", maxIter, f));
         return f;
         return f;
     }
     }
 
 

+ 7 - 0
jplag/src/main/java/de/jplag/options/JPlagOptions.java

@@ -317,6 +317,13 @@ public class JPlagOptions {
         this.languageOption = languageOption;
         this.languageOption = languageOption;
     }
     }
 
 
+    public void setMaximumNumberOfComparisons(int maximumNumberOfComparisons) {
+        if (maximumNumberOfComparisons < -1) {
+            this.maximumNumberOfComparisons = -1;
+        } else {
+            this.maximumNumberOfComparisons = maximumNumberOfComparisons;
+        }
+    }
 
 
     public SimilarityMetric getClusteringSimilarityMetric() {
     public SimilarityMetric getClusteringSimilarityMetric() {
         return clusteringSimilarityMetric;
         return clusteringSimilarityMetric;