Skip to content

Commit 067d534

Browse files
apply fixes to match latest test syntaxes
1 parent 35f30cf commit 067d534

18 files changed

+187
-48
lines changed

docs/code_samples/default_v2.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import com.mindee.MindeeClientV2;
2-
import com.mindee.InferencePredictOptions;
2+
import com.mindee.InferenceOptions;
33
import com.mindee.input.LocalInputSource;
44
import com.mindee.parsing.v2.InferenceResponse;
55
import java.io.File;
@@ -19,7 +19,7 @@ public class SimpleMindeeClient {
1919

2020
// Prepare the enqueueing options
2121
// Note: modelId is mandatory.
22-
InferencePredictOptions options = InferencePredictOptions.builder("MY_MODEL_ID").build();
22+
InferenceOptions options = InferenceOptions.builder("MY_MODEL_ID").build();
2323

2424
// Parse the file
2525
InferenceResponse response = mindeeClient.enqueueAndParse(

src/main/java/com/mindee/InferencePredictOptions.java renamed to src/main/java/com/mindee/InferenceOptions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
@Getter
1414
@Data
15-
public final class InferencePredictOptions {
15+
public final class InferenceOptions {
1616
/**
1717
* ID of the model (required).
1818
*/
@@ -54,7 +54,7 @@ public static Builder builder(String modelId) {
5454
}
5555

5656
/**
57-
* Fluent builder for {@link InferencePredictOptions}.
57+
* Fluent builder for {@link InferenceOptions}.
5858
*/
5959
public static final class Builder {
6060

@@ -106,9 +106,9 @@ public Builder pollingOptions(AsyncPollingOptions pollingOptions) {
106106
return this;
107107
}
108108

109-
/** Build an immutable {@link InferencePredictOptions} instance. */
110-
public InferencePredictOptions build() {
111-
return new InferencePredictOptions(
109+
/** Build an immutable {@link InferenceOptions} instance. */
110+
public InferenceOptions build() {
111+
return new InferenceOptions(
112112
modelId,
113113
fullText,
114114
rag,

src/main/java/com/mindee/MindeeClientV2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public MindeeClientV2(PdfOperation pdfOperation, MindeeApiV2 mindeeApi) {
4444
*/
4545
public JobResponse enqueue(
4646
LocalInputSource inputSource,
47-
InferencePredictOptions options) throws IOException {
47+
InferenceOptions options) throws IOException {
4848
LocalInputSource finalInput;
4949
if (options.getPageOptions() != null) {
5050
finalInput = new LocalInputSource(getSplitFile(inputSource, options.getPageOptions()), inputSource.getFilename());
@@ -74,7 +74,7 @@ public CommonResponse parseQueued(String jobId) {
7474
*/
7575
public InferenceResponse enqueueAndParse(
7676
LocalInputSource inputSource,
77-
InferencePredictOptions options) throws IOException, InterruptedException {
77+
InferenceOptions options) throws IOException, InterruptedException {
7878

7979
validatePollingOptions(options.getPollingOptions());
8080

src/main/java/com/mindee/http/MindeeApiV2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.mindee.http;
22

3-
import com.mindee.InferencePredictOptions;
3+
import com.mindee.InferenceOptions;
44
import com.mindee.input.LocalInputSource;
55
import com.mindee.parsing.v2.CommonResponse;
66
import com.mindee.parsing.v2.JobResponse;
@@ -15,7 +15,7 @@ abstract public class MindeeApiV2 extends MindeeApiCommon {
1515
*/
1616
abstract public JobResponse enqueuePost(
1717
LocalInputSource inputSource,
18-
InferencePredictOptions options
18+
InferenceOptions options
1919
) throws IOException;
2020

2121
/**

src/main/java/com/mindee/http/MindeeHttpApiV2.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mindee.http;
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
4-
import com.mindee.InferencePredictOptions;
4+
import com.mindee.InferenceOptions;
55
import com.mindee.MindeeException;
66
import com.mindee.MindeeSettingsV2;
77
import com.mindee.input.LocalInputSource;
@@ -74,7 +74,7 @@ private MindeeHttpApiV2(
7474
*/
7575
public JobResponse enqueuePost(
7676
LocalInputSource inputSource,
77-
InferencePredictOptions options
77+
InferenceOptions options
7878
) {
7979
String url = this.mindeeSettings.getBaseUrl() + "/inferences/enqueue";
8080
HttpPost post = buildHttpPost(url, inputSource, options);
@@ -149,7 +149,7 @@ private MindeeHttpExceptionV2 getHttpError(ClassicHttpResponse response) {
149149

150150
private HttpEntity buildHttpBody(
151151
LocalInputSource inputSource,
152-
InferencePredictOptions options
152+
InferenceOptions options
153153
) {
154154
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
155155
builder.setMode(HttpMultipartMode.EXTENDED);
@@ -187,7 +187,7 @@ private HttpEntity buildHttpBody(
187187
private HttpPost buildHttpPost(
188188
String url,
189189
LocalInputSource inputSource,
190-
InferencePredictOptions options
190+
InferenceOptions options
191191
) {
192192
HttpPost post;
193193
try {

src/main/java/com/mindee/parsing/v2/Inference.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,19 @@ public class Inference {
4343

4444
@Override
4545
public String toString() {
46-
StringJoiner sj = new StringJoiner("\n");
47-
sj.add("#########")
46+
StringJoiner joiner = new StringJoiner("\n");
47+
joiner
4848
.add("Inference")
4949
.add("#########")
50-
.add(":Model: " + (model != null ? model.getId() : ""))
51-
.add(":File:")
52-
.add(" :Name: " + (file != null ? file.getName() : ""))
53-
.add(" :Alias: " + (file != null ? file.getAlias() : ""))
50+
.add("Model")
51+
.add("=====")
52+
.add(":ID: " + (model != null ? model.getId() : ""))
53+
.add("")
54+
.add("File")
55+
.add("====")
56+
.add(file != null ? file.toString() : "")
5457
.add("")
55-
.add("Result")
56-
.add("======")
5758
.add(result != null ? result.toString() : "");
58-
return sj.toString().trim();
59+
return joiner.toString().trim() + "\n";
5960
}
6061
}

src/main/java/com/mindee/parsing/v2/InferenceResult.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ public final class InferenceResult {
3434
@Override
3535
public String toString() {
3636
StringJoiner joiner = new StringJoiner("\n");
37+
joiner.add("Fields")
38+
.add("======");
3739
joiner.add(fields.toString());
38-
if (options != null) {
39-
joiner.add(options.toString());
40+
if (this.getOptions() != null) {
41+
joiner.add("Options")
42+
.add("=======")
43+
.add(this.getOptions().toString());
4044
}
4145
return joiner.toString();
4246
}

src/main/java/com/mindee/parsing/v2/InferenceResultFile.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ public class InferenceResultFile {
2727
*/
2828
@JsonProperty("alias")
2929
private String alias;
30+
31+
public String toString() {
32+
return ":Name: " + name + "\n:Alias:" + (alias != null ? " " + alias : "");
33+
}
3034
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
package com.mindee.parsing.v2.field;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.util.List;
5+
36
/**
47
* Base class for V2 fields.
58
*/
69
public abstract class BaseField {
10+
/**
11+
* Field's location.
12+
*/
13+
@JsonProperty("locations")
14+
private List<FieldLocation> page;
715

16+
/**
17+
* Confidence associated with the field.
18+
*/
19+
@JsonProperty("confidence")
20+
private FieldConfidence confidence;
821
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.mindee.parsing.v2.field;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonValue;
5+
6+
/**
7+
* Confidence level of a field as returned by the V2 API.
8+
*/
9+
public enum FieldConfidence {
10+
Certain("Certain"),
11+
High("High"),
12+
Medium("Medium"),
13+
Low("Low");
14+
15+
private final String json;
16+
17+
FieldConfidence(String json) {
18+
this.json = json;
19+
}
20+
21+
@JsonValue
22+
public String toJson() {
23+
return json;
24+
}
25+
26+
@JsonCreator
27+
public static FieldConfidence fromJson(String value) {
28+
if (value == null) {
29+
return null;
30+
}
31+
for (FieldConfidence level : values()) {
32+
if (level.json.equalsIgnoreCase(value)) {
33+
return level;
34+
}
35+
}
36+
throw new IllegalArgumentException("Unknown confidence level '" + value + "'.");
37+
}
38+
}

0 commit comments

Comments
 (0)