-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathv2_extraction.txt
More file actions
55 lines (44 loc) · 1.71 KB
/
v2_extraction.txt
File metadata and controls
55 lines (44 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import com.mindee.MindeeClientV2;
import com.mindee.InferenceParameters;
import com.mindee.input.LocalInputSource;
import com.mindee.parsing.v2.InferenceResponse;
import com.mindee.parsing.v2.field.InferenceFields;
import java.io.IOException;
public class SimpleMindeeClientV2 {
public static void main(String[] args)
throws IOException, InterruptedException
{
String apiKey = "MY_API_KEY";
String filePath = "/path/to/the/file.ext";
String modelId = "MY_MODEL_ID";
// Init a new client
MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);
// Set inference parameters
InferenceParameters extractionParams = InferenceParameters
// ID of the model, required.
.builder(modelId)
// Options: set to `true` or `false` to override defaults
// Enhance extraction accuracy with Retrieval-Augmented Generation.
.rag(null)
// Extract the full text content from the document as strings.
.rawText(null)
// Calculate bounding box polygons for all fields.
.polygon(null)
// Boost the precision and accuracy of all extractions.
// Calculate confidence scores for all fields.
.confidence(null)
.build();
// Load a file from disk
LocalInputSource inputSource = new LocalInputSource(filePath);
// Send for processing using polling
InferenceResponse response = mindeeClient.enqueueAndGetResult(
InferenceResponse.class,
inputSource,
extractionParams
);
// Print a summary of the response
System.out.println(response.getInference().toString());
// Access the result fields
InferenceFields fields = response.getInference().getResult().getFields();
}
}