Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,26 @@
public class CategoriesOptions extends Options {

/**
* @deprecated
* Users should use {@link singleLabel} to return only one result
* or {@link scoreThreshold} to filter results based on raw score
* @return number of categories
*/
@Min(1)
private final Integer numCategories;

/**
* Single label mode will return only the highest scoring category, regardless of score
* If singleLabel is false, every category whose score exceeds the default
* (or specified) {@link scoreThreshold} value will be returned
* @return whether or not we are in single label mode
*/
private final Boolean singleLabel;

/**
* threshold against the category's raw score, whose value
* can be any real number.
* @return the score threshold
*/
private final Float scoreThreshold;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe worthwhile to clarify that the threshold will be ignored if singleLabel is true, especially if the single label score falls below the threshold? or did I interpret it wrong?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turning on singleLabel automatically sets scoreThreshold to -INF, but this will get overridden if scoreThreshold is also specified. I'll add a clarifying note to singleLabel that the highest scoring category gets returned regardless of score (although after talking to Hannah we may hold off on exposing the raw score altogether, so this may all be moot)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So not merging yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got the okay from Hannah, so we're sticking with these changes. Just waiting on the verification.

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ public class CategoriesResponse extends Response {
/**
* @return a list of categories
*/
private final List<Label> categories;
private final List<CategoryLabel> categories;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2018 Basis Technology Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.basistech.rosette.apimodel;

import com.basistech.rosette.annotations.JacksonMixin;
import lombok.Builder;
import lombok.Value;

@Value
@Builder
@JacksonMixin
public class CategoryLabel {

/**
* @return the label.
*/
private final String label;

/**
* @return the confidence score (0.0-1.0)
*/
private final Double confidence;

/**
* @return the raw score (-INF-INF)
*/
private final Double score;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@EqualsAndHashCode
@Builder
@JacksonMixin
public class SentimentResponse extends Response {
public class SentimentResponse extends Response {

/**
* @return the whole-document sentiment.
Expand Down