Skip to content

Commit

Permalink
Refactored: Altered the way the if statement skips to the next loop
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLukeKR committed Apr 21, 2018
1 parent de8d99f commit 51f0f80
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main/java/Processing/NaturalLanguageProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,13 @@ private static double calculateSentiment(ArrayList<String> wordList) throws SQLE
for (String word : wordList) {
ArrayList<String> results = dh.executeQuery("SELECT Increase, Decrease FROM ngrams WHERE Hash=MD5('" + word + "');");

if (!results.isEmpty()) {
if (results.isEmpty()) continue;
String result = results.get(0);

String[] splitResult = result.split(",");
double increase = Double.parseDouble(splitResult[0]), decrease = Integer.parseInt(splitResult[1]);
double sentiment = increase / (increase + decrease);
double increase = Double.parseDouble(splitResult[0]), decrease = Double.parseDouble(splitResult[1]);

totalSentiment += sentiment;
}
totalSentiment += increase / (increase + decrease);
}

return totalSentiment / wordList.size();
Expand Down

0 comments on commit 51f0f80

Please sign in to comment.