Skip to content

Commit ca55857

Browse files
iredpathcp2boston
authored andcommitted
RD-2101 expose salience threshold option for topics (#105)
* RD-2101 expose salience threshold option for topics * RD-2101 correct file header * RD-2101 typo
1 parent 16c2518 commit ca55857

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

json/src/main/java/com/basistech/rosette/apimodel/jackson/ApiModelMixinModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import com.basistech.rosette.apimodel.SyntaxDependenciesResponse;
6363
import com.basistech.rosette.apimodel.TextEmbeddingResponse;
6464
import com.basistech.rosette.apimodel.TokensResponse;
65+
import com.basistech.rosette.apimodel.TopicsOptions;
6566
import com.basistech.rosette.apimodel.TopicsResponse;
6667
import com.basistech.rosette.apimodel.TransliterationOptions;
6768
import com.basistech.rosette.apimodel.TransliterationResponse;
@@ -132,6 +133,7 @@ public void setupModule(Module.SetupContext context) {
132133
context.setMixInAnnotations(Options.class, OptionsMixin.class);
133134
context.setMixInAnnotations(TransliterationOptions.class, TransliterationOptionsMixin.class);
134135
context.setMixInAnnotations(TransliterationResponse.class, TransliterationResponseMixin.class);
136+
context.setMixInAnnotations(TopicsOptions.class, TopicsOptionsMixin.class);
135137
context.setMixInAnnotations(TopicsResponse.class, TopicsResponseMixin.class);
136138
context.setMixInAnnotations(Keyphrase.class, KeyphraseMixin.class);
137139
context.setMixInAnnotations(Concept.class, ConceptMixin.class);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2017 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.jackson;
17+
18+
import com.fasterxml.jackson.annotation.JsonCreator;
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
21+
public class TopicsOptionsMixin extends BaseMixin {
22+
@JsonCreator
23+
protected TopicsOptionsMixin(@JsonProperty("conceptSalienceThreshold") final Double conceptSalienceThreshold,
24+
@JsonProperty("keyphraseSalienceThreshold") final Double keyphraseSalienceThreshold) {
25+
//
26+
}
27+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2017 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 javax.validation.constraints.DecimalMax;
19+
import javax.validation.constraints.DecimalMin;
20+
import java.util.Objects;
21+
22+
public final class TopicsOptions extends Options {
23+
@DecimalMin("0.0")
24+
@DecimalMax("1.0")
25+
private Double conceptSalienceThreshold;
26+
@DecimalMin("0.0")
27+
@DecimalMax("1.0")
28+
private Double keyphraseSalienceThreshold;
29+
30+
public TopicsOptions(Double conceptSalienceThreshold, Double keyphraseSalienceThreshold) {
31+
this.conceptSalienceThreshold = conceptSalienceThreshold;
32+
this.keyphraseSalienceThreshold = keyphraseSalienceThreshold;
33+
}
34+
35+
public Double getconceptSalienceThreshold() {
36+
return conceptSalienceThreshold;
37+
}
38+
39+
public Double getkeyphraseSalienceThreshold() {
40+
return keyphraseSalienceThreshold;
41+
}
42+
43+
@Override
44+
public boolean equals(final Object obj) {
45+
if (this == obj) {
46+
return true;
47+
} else if (obj == null || getClass() != obj.getClass()) {
48+
return false;
49+
}
50+
final TopicsOptions that = (TopicsOptions) obj;
51+
return Objects.equals(conceptSalienceThreshold, that.conceptSalienceThreshold)
52+
&& Objects.equals(keyphraseSalienceThreshold, that.keyphraseSalienceThreshold);
53+
}
54+
55+
@Override
56+
public int hashCode() {
57+
return Objects.hash(conceptSalienceThreshold, keyphraseSalienceThreshold);
58+
}
59+
60+
public static class Builder {
61+
private Double conceptSalienceThreshold;
62+
private Double keyphraseSalienceThreshold;
63+
64+
public Builder() {
65+
//
66+
}
67+
68+
public Builder conceptSalienceThreshold(Double conceptSalienceThreshold) {
69+
this.conceptSalienceThreshold = conceptSalienceThreshold;
70+
return this;
71+
}
72+
73+
74+
public Builder keyphraseSalienceThreshold(Double keyphraseSalienceThreshold) {
75+
this.keyphraseSalienceThreshold = keyphraseSalienceThreshold;
76+
return this;
77+
}
78+
79+
public TopicsOptions build() {
80+
return new TopicsOptions(conceptSalienceThreshold, keyphraseSalienceThreshold);
81+
}
82+
}
83+
84+
}

0 commit comments

Comments
 (0)