Skip to content

Commit

Permalink
Tweak null confidence case to allow populating feedback label list (#166
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Cyborger1 authored Oct 19, 2022
1 parent ddbd85d commit 65a1295
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/botdetector/http/BotDetectorClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,13 @@ public void onResponse(Call call, Response response)

/**
* Requests a bot prediction for the given {@code playerName}.
* Breakdown will not be provided in special cases (see {@link BotDetectorClient#requestPrediction(String, boolean)}).
* Breakdown will be provided by default in special cases (see {@link BotDetectorClient#requestPrediction(String, boolean)}).
* @param playerName The player name to predict.
* @return A future that will eventually return the player's bot prediction.
*/
public CompletableFuture<Prediction> requestPrediction(String playerName)
{
return requestPrediction(playerName, false);
return requestPrediction(playerName, true);
}

/**
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/com/botdetector/ui/BotDetectorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,7 @@ public void setPrediction(Prediction pred, PlayerSighting sighting)
feedbackLabelComboBox.setSelectedItem(UNSURE_PREDICTION_LABEL);
feedbackLabelComboBox.addItem(SOMETHING_ELSE_PREDICTION_LABEL);

if (pred.getPredictionBreakdown() == null || pred.getPredictionBreakdown().size() == 0
|| (isNullConfidence && !config.showBreakdownOnNullConfidence()))
if (pred.getPredictionBreakdown() == null || pred.getPredictionBreakdown().size() == 0)
{
predictionBreakdownLabel.setText(EMPTY_LABEL);
predictionBreakdownPanel.setVisible(false);
Expand All @@ -1113,8 +1112,16 @@ public void setPrediction(Prediction pred, PlayerSighting sighting)
}
else
{
predictionBreakdownLabel.setText(toPredictionBreakdownString(pred.getPredictionBreakdown()));
predictionBreakdownPanel.setVisible(true);
if (isNullConfidence && !config.showBreakdownOnNullConfidence())
{
predictionBreakdownLabel.setText(EMPTY_LABEL);
predictionBreakdownPanel.setVisible(false);
}
else
{
predictionBreakdownLabel.setText(toPredictionBreakdownString(pred.getPredictionBreakdown()));
predictionBreakdownPanel.setVisible(true);
}

final String primaryLabel = pred.getPredictionLabel();

Expand Down Expand Up @@ -1272,9 +1279,7 @@ else if (!isValidPlayerName(target))

setPrediction(null);

// Note: The showBreakdown parameter is redundant due to the null confidence checks added, but we're including it for now.
// If to be removed, ensure the API breakdown parameter is always true.
detectorClient.requestPrediction(target, config.showBreakdownOnNullConfidence()).whenCompleteAsync((pred, ex) ->
detectorClient.requestPrediction(target).whenCompleteAsync((pred, ex) ->
SwingUtilities.invokeLater(() ->
{
if (!sanitize(searchBar.getText()).equals(target))
Expand Down

0 comments on commit 65a1295

Please sign in to comment.