Skip to content

Commit

Permalink
Merge pull request #177 from SOBotics/hotfix/176-reason-string
Browse files Browse the repository at this point in the history
Hotfix/176 reason string
  • Loading branch information
FelixSFD authored May 20, 2018
2 parents 4749f01 + 589eaa1 commit dc1461b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.felixsfd.stackoverflow</groupId>
<artifactId>guttenberg</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>

<dependencies>
<dependency>
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/sobotics/guttenberg/entities/PostMatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public List<PostMatch> 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));
Expand All @@ -193,6 +193,8 @@ public List<PostMatch> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sobotics/guttenberg/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit dc1461b

Please sign in to comment.