From 4270cedfc3dfe51e66aaeca320e668d5e4cefdff Mon Sep 17 00:00:00 2001 From: FelixSFD Date: Sun, 20 May 2018 15:08:33 +0200 Subject: [PATCH 1/2] #176: - fixed bug where reason wasn't added to CP-string --- .../org/sobotics/guttenberg/entities/PostMatch.java | 10 +++++++--- .../org/sobotics/guttenberg/finders/PlagFinder.java | 4 +++- .../sobotics/guttenberg/reasons/StringSimilarity.java | 4 ++-- .../java/org/sobotics/guttenberg/utils/FileUtils.java | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/sobotics/guttenberg/entities/PostMatch.java b/src/main/java/org/sobotics/guttenberg/entities/PostMatch.java index e04768b..6b5e4de 100644 --- a/src/main/java/org/sobotics/guttenberg/entities/PostMatch.java +++ b/src/main/java/org/sobotics/guttenberg/entities/PostMatch.java @@ -47,18 +47,22 @@ public void addReason(String reason, double score) { } } + /** + * Adds the reason to the String sent to CopyPastor + * (can't be called by addReason() because this would include the score in the description) + * */ public void addReasonToCopyPastorString(String reason, double score) { - LOGGER.trace("Adding reason \"" + reason + "\" (Score: " + score + ") to string for CopyPastor"); + LOGGER.debug("Adding reason \"" + reason + "\" (Score: " + score + ") to string for CopyPastor"); //#171: don't check the array. Check the String instead if (!copyPastorReasonString.contains(reason)) { - LOGGER.trace("Reason doesn't exist in string yet"); + LOGGER.debug("Reason doesn't exist in string yet"); double roundedScore = Math.round(score*100.0)/100.0; if (copyPastorReasonString.length() > 0) this.copyPastorReasonString += ","; this.copyPastorReasonString += reason + ":" + roundedScore; - LOGGER.trace("New copyPastorReasonString: " + this.copyPastorReasonString); + LOGGER.debug("New copyPastorReasonString: " + this.copyPastorReasonString); } } diff --git a/src/main/java/org/sobotics/guttenberg/finders/PlagFinder.java b/src/main/java/org/sobotics/guttenberg/finders/PlagFinder.java index c38466f..c54b1c3 100644 --- a/src/main/java/org/sobotics/guttenberg/finders/PlagFinder.java +++ b/src/main/java/org/sobotics/guttenberg/finders/PlagFinder.java @@ -178,7 +178,7 @@ public List matchesForReasons(boolean ignoringScores) { if (existingMatch.getOriginal().getAnswerID() == id) { //if it exists, add the new reason alreadyExists = true; - LOGGER.trace("Adding reason " + reason.description(i) + " with score " + scores.get(n)); + LOGGER.debug("Adding reason " + reason.description(i) + " with score " + scores.get(n)); existingMatch.addReason(reason.description(i), scores.get(n)); existingMatch.addReasonToCopyPastorString(reason.description(i, false), scores.get(n)); @@ -193,6 +193,8 @@ public List matchesForReasons(boolean ignoringScores) { if (!alreadyExists) { PostMatch newMatch = new PostMatch(this.targetAnswer, post); newMatch.addReason(reason.description(i), scores.get(n)); + //#176: add the reason to the string for CopyPastor as well + newMatch.addReasonToCopyPastorString(reason.description(i, false), scores.get(n)); LOGGER.trace("Adding PostMatch " + newMatch); matches.add(newMatch); } diff --git a/src/main/java/org/sobotics/guttenberg/reasons/StringSimilarity.java b/src/main/java/org/sobotics/guttenberg/reasons/StringSimilarity.java index df37115..d7347f9 100644 --- a/src/main/java/org/sobotics/guttenberg/reasons/StringSimilarity.java +++ b/src/main/java/org/sobotics/guttenberg/reasons/StringSimilarity.java @@ -85,7 +85,7 @@ public static double similarityOf(Post targetPost, Post originalPost) { double jwQuotes = originalQuotes != null ? ( jw.similarity(originalQuotes, targetQuotes) * quantifierQuotes) : 0; - LOGGER.debug("bodyMarkdown: "+jwBodyMarkdown+"; codeOnly: "+jwCodeOnly+"; plaintext: "+jwPlaintext); + LOGGER.trace("bodyMarkdown: "+jwBodyMarkdown+"; codeOnly: "+jwCodeOnly+"; plaintext: "+jwPlaintext); double usedScores = (jwBodyMarkdown > 0 ? quantifierBodyMarkdown : 0) + (jwCodeOnly > 0 ? quantifierCodeOnly : 0) @@ -96,7 +96,7 @@ public static double similarityOf(Post targetPost, Post originalPost) { + (jwPlaintext > 0 ? jwPlaintext : 0) + (jwQuotes > 0 ? jwQuotes : 0)) / usedScores; - LOGGER.debug("Score: "+jaroWinklerScore); + LOGGER.trace("Score: "+jaroWinklerScore); if (jwBodyMarkdown > 0.9) { return jwBodyMarkdown; diff --git a/src/main/java/org/sobotics/guttenberg/utils/FileUtils.java b/src/main/java/org/sobotics/guttenberg/utils/FileUtils.java index 5911437..3ea16bf 100644 --- a/src/main/java/org/sobotics/guttenberg/utils/FileUtils.java +++ b/src/main/java/org/sobotics/guttenberg/utils/FileUtils.java @@ -149,7 +149,7 @@ public static Properties getPropertiesFromFile(String filepath) throws IOExcepti try { prop = new Properties(); prop.load(fis); - LOGGER.debug("Succesffully loaded"); + LOGGER.trace("Succesffully loaded"); } //try finally { if (fis != null) { From 589eaa1856d4134b097d1e4bbce45bf040c5586a Mon Sep 17 00:00:00 2001 From: FelixSFD Date: Sun, 20 May 2018 15:12:47 +0200 Subject: [PATCH 2/2] - bump version to 1.2.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b33b93..066540f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ de.felixsfd.stackoverflow guttenberg - 1.2.1 + 1.2.2