|
| 1 | +import com.mindee.MindeeClient; |
| 2 | +import com.mindee.input.LocalInputSource; |
| 3 | +import com.mindee.parsing.common.AsyncPredictResponse; |
| 4 | +import com.mindee.product.internationalid.InternationalIdV2; |
| 5 | +import java.io.File; |
| 6 | +import java.io.IOException; |
| 7 | + |
| 8 | +public class SimpleMindeeClient { |
| 9 | + |
| 10 | + public static void main(String[] args) throws IOException, InterruptedException { |
| 11 | + String apiKey = "my-api-key"; |
| 12 | + String filePath = "/path/to/the/file.ext"; |
| 13 | + |
| 14 | + // Init a new client |
| 15 | + MindeeClient mindeeClient = new MindeeClient(apiKey); |
| 16 | + |
| 17 | + // Load a file from disk |
| 18 | + LocalInputSource inputSource = new LocalInputSource(new File(filePath)); |
| 19 | + |
| 20 | + // Parse the file asynchronously |
| 21 | + AsyncPredictResponse<InternationalIdV2> response = mindeeClient.enqueueAndParse( |
| 22 | + InternationalIdV2.class, |
| 23 | + inputSource |
| 24 | + ); |
| 25 | + |
| 26 | + // Print a summary of the response |
| 27 | + System.out.println(response.toString()); |
| 28 | + |
| 29 | + // Print a summary of the predictions |
| 30 | +// System.out.println(response.getDocumentObj().toString()); |
| 31 | + |
| 32 | + // Print the document-level predictions |
| 33 | +// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); |
| 34 | + |
| 35 | + // Print the page-level predictions |
| 36 | +// response.getDocumentObj().getInference().getPages().forEach( |
| 37 | +// page -> System.out.println(page.toString()) |
| 38 | +// ); |
| 39 | + } |
| 40 | + |
| 41 | +} |
0 commit comments