Skip to content

Commit eb25416

Browse files
authored
Merge pull request #131 from iredpath/RD-2360-multilabel-tcat
RD-2360 deprecate numCategories, add singleLabel, scoreThreshold opti…
2 parents 98fdcbf + d5dce1b commit eb25416

4 files changed

Lines changed: 61 additions & 2 deletions

File tree

model/src/main/java/com/basistech/rosette/apimodel/CategoriesOptions.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,26 @@
3131
public class CategoriesOptions extends Options {
3232

3333
/**
34+
* @deprecated
35+
* Users should use {@link singleLabel} to return only one result
36+
* or {@link scoreThreshold} to filter results based on raw score
3437
* @return number of categories
3538
*/
3639
@Min(1)
3740
private final Integer numCategories;
41+
42+
/**
43+
* Single label mode will return only the highest scoring category, regardless of score
44+
* If singleLabel is false, every category whose score exceeds the default
45+
* (or specified) {@link scoreThreshold} value will be returned
46+
* @return whether or not we are in single label mode
47+
*/
48+
private final Boolean singleLabel;
49+
50+
/**
51+
* threshold against the category's raw score, whose value
52+
* can be any real number.
53+
* @return the score threshold
54+
*/
55+
private final Float scoreThreshold;
3856
}

model/src/main/java/com/basistech/rosette/apimodel/CategoriesResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ public class CategoriesResponse extends Response {
3535
/**
3636
* @return a list of categories
3737
*/
38-
private final List<Label> categories;
38+
private final List<CategoryLabel> categories;
3939
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2018 Basis Technology Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.basistech.rosette.apimodel;
17+
18+
import com.basistech.rosette.annotations.JacksonMixin;
19+
import lombok.Builder;
20+
import lombok.Value;
21+
22+
@Value
23+
@Builder
24+
@JacksonMixin
25+
public class CategoryLabel {
26+
27+
/**
28+
* @return the label.
29+
*/
30+
private final String label;
31+
32+
/**
33+
* @return the confidence score (0.0-1.0)
34+
*/
35+
private final Double confidence;
36+
37+
/**
38+
* @return the raw score (-INF-INF)
39+
*/
40+
private final Double score;
41+
}

model/src/main/java/com/basistech/rosette/apimodel/SentimentResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
@EqualsAndHashCode
3131
@Builder
3232
@JacksonMixin
33-
public class SentimentResponse extends Response {
33+
public class SentimentResponse extends Response {
3434

3535
/**
3636
* @return the whole-document sentiment.

0 commit comments

Comments
 (0)