Skip to content

Commit 198628b

Browse files
Merge pull request #204 from rosette-api/WS-2744-restore-genre
WS-2744: restore genre
2 parents 3833d4a + 49c8745 commit 198628b

File tree

13 files changed

+40
-11
lines changed

13 files changed

+40
-11
lines changed

annotations/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>com.basistech.rosette</groupId>
2121
<artifactId>rosette-api-java-binding</artifactId>
22-
<version>1.25.1-SNAPSHOT</version>
22+
<version>1.25.101-SNAPSHOT</version>
2323
</parent>
2424
<artifactId>rosette-api-annotations</artifactId>
2525
<name>rosette-api-annotations</name>

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>com.basistech.rosette</groupId>
2121
<artifactId>rosette-api-java-binding</artifactId>
22-
<version>1.25.1-SNAPSHOT</version>
22+
<version>1.25.101-SNAPSHOT</version>
2323
</parent>
2424
<artifactId>rosette-api</artifactId>
2525
<name>rosette-api</name>

common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>com.basistech.rosette</groupId>
2121
<artifactId>rosette-api-java-binding</artifactId>
22-
<version>1.25.1-SNAPSHOT</version>
22+
<version>1.25.101-SNAPSHOT</version>
2323
</parent>
2424
<artifactId>rosette-api-common</artifactId>
2525
<name>rosette-api-common</name>

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>com.basistech.rosette</groupId>
2222
<artifactId>rosette-api-java-binding</artifactId>
23-
<version>1.25.1-SNAPSHOT</version>
23+
<version>1.25.101-SNAPSHOT</version>
2424
</parent>
2525
<groupId>com.basistech.rosette</groupId>
2626
<artifactId>rosette-api-examples</artifactId>

json/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>com.basistech.rosette</groupId>
2222
<artifactId>rosette-api-java-binding</artifactId>
23-
<version>1.25.1-SNAPSHOT</version>
23+
<version>1.25.101-SNAPSHOT</version>
2424
</parent>
2525
<artifactId>rosette-api-json</artifactId>
2626
<name>rosette-api-json</name>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.basistech.util.LanguageCode;
2121
import com.fasterxml.jackson.annotation.JsonCreator;
2222
import com.fasterxml.jackson.annotation.JsonIgnore;
23+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2324
import com.fasterxml.jackson.annotation.JsonInclude;
2425
import com.fasterxml.jackson.annotation.JsonProperty;
2526
import com.fasterxml.jackson.annotation.JsonTypeName;
@@ -30,6 +31,7 @@
3031

3132
//CHECKSTYLE:OFF
3233
@JsonTypeName("DocumentRequest")
34+
@JsonIgnoreProperties({"genre"})
3335
@JsonInclude(JsonInclude.Include.NON_NULL)
3436
public abstract class DocumentRequestMixin {
3537

json/src/test/java/com/basistech/rosette/apimodel/ModelTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818

1919
import com.basistech.rosette.apimodel.jackson.ApiModelMixinModule;
2020
import com.basistech.rosette.apimodel.jackson.DocumentRequestMixin;
21+
import com.fasterxml.jackson.core.JsonProcessingException;
22+
import com.fasterxml.jackson.core.type.TypeReference;
2123
import com.fasterxml.jackson.databind.ObjectMapper;
2224
import com.fasterxml.jackson.databind.ObjectWriter;
2325
import com.google.common.collect.Lists;
2426
import org.junit.jupiter.api.BeforeEach;
27+
import org.junit.jupiter.api.Test;
2528
import org.junit.jupiter.params.ParameterizedTest;
2629
import org.junit.jupiter.params.provider.Arguments;
2730
import org.junit.jupiter.params.provider.MethodSource;
@@ -43,6 +46,7 @@
4346
import java.util.stream.Stream;
4447

4548
import static org.junit.jupiter.api.Assertions.assertEquals;
49+
import static org.junit.jupiter.api.Assertions.assertTrue;
4650
import static org.junit.jupiter.api.Assertions.fail;
4751

4852
@SuppressWarnings("PMD.UnusedPrivateMethod") // Parameterized Tests
@@ -376,4 +380,12 @@ private Object createObjectOfType(Type type) {
376380
}
377381
return object;
378382
}
383+
384+
@Test
385+
void doNotDeserializeGenre() throws JsonProcessingException {
386+
String json = "{\"content\": \"foo\", \"genre\":\"foo\"}";
387+
// Ensure that the document request no longer deserializes genre
388+
Request request = mapper.readValue(json, new TypeReference<DocumentRequest<EntitiesOptions>>() { });
389+
assertTrue(mapper.writeValueAsString(request).indexOf("genre") == -1);
390+
}
379391
}

json/src/test/java/com/basistech/rosette/apimodel/PolymorphicRequestTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ public void init() {
3838
@Test
3939
void testRequestTypes() throws Exception {
4040

41-
String json = "{\"content\": \"what is my type\", \"language\": \"eng\", \"options\": {\"calculateConfidence\": true}}";
41+
String json = "{\"content\": \"what is my type\", \"language\": \"eng\", \"genre\": \"news\"}";
4242
Request request = mapper.readValue(json, new TypeReference<DocumentRequest<EntitiesOptions>>() { });
4343
assertEquals(DOC_REQUEST, request.getClass().getName());
4444

45+
json = "{\"content\": \"what is my type\", \"language\": \"eng\", \"options\": {\"calculateConfidence\": true}}";
46+
request = mapper.readValue(json, new TypeReference<DocumentRequest<EntitiesOptions>>() { });
47+
assertEquals(DOC_REQUEST, request.getClass().getName());
48+
4549
json = "{\"content\": \"what is my type\", \"language\": \"eng\", \"options\": {\"includeDBpediaTypes\": true, \"calculateConfidence\": true}}";
4650
request = mapper.readValue(json, new TypeReference<DocumentRequest<EntitiesOptions>>() { });
4751
assertEquals(DOC_REQUEST, request.getClass().getName());

model/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>com.basistech.rosette</groupId>
2121
<artifactId>rosette-api-java-binding</artifactId>
22-
<version>1.25.1-SNAPSHOT</version>
22+
<version>1.25.101-SNAPSHOT</version>
2323
</parent>
2424
<artifactId>rosette-api-model</artifactId>
2525
<name>rosette-api-model</name>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.basistech.rosette.apimodel;
1818

1919
import com.basistech.rosette.annotations.JacksonMixin;
20+
import javax.validation.constraints.Min;
2021
import lombok.Builder;
2122
import lombok.Value;
2223

@@ -28,6 +29,16 @@
2829
@JacksonMixin
2930
public class CategoriesOptions extends Options {
3031

32+
/**
33+
* @deprecated
34+
* Users should use {@link singleLabel} to return only one result
35+
* or {@link scoreThreshold} to filter results based on raw score
36+
* @return number of categories
37+
*/
38+
@Deprecated
39+
@Min(1)
40+
private final Integer numCategories;
41+
3142
/**
3243
* Single label mode will return only the highest scoring category, regardless of score
3344
* If singleLabel is false, every category whose score exceeds the default

0 commit comments

Comments
 (0)