Search in sources :

Example 1 with StartDocumentAnalysisRequest

use of software.amazon.awssdk.services.textract.model.StartDocumentAnalysisRequest in project aws-doc-sdk-examples by awsdocs.

the class StartDocumentAnalysis method startDocAnalysisS3.

// snippet-start:[textract.java2._start_doc_analysis.main]
public static String startDocAnalysisS3(TextractClient textractClient, String bucketName, String docName) {
    try {
        List<FeatureType> myList = new ArrayList<FeatureType>();
        myList.add(FeatureType.TABLES);
        myList.add(FeatureType.FORMS);
        S3Object s3Object = S3Object.builder().bucket(bucketName).name(docName).build();
        DocumentLocation location = DocumentLocation.builder().s3Object(s3Object).build();
        StartDocumentAnalysisRequest documentAnalysisRequest = StartDocumentAnalysisRequest.builder().documentLocation(location).featureTypes(myList).build();
        StartDocumentAnalysisResponse response = textractClient.startDocumentAnalysis(documentAnalysisRequest);
        // Get the job ID
        String jobId = response.jobId();
        return jobId;
    } catch (TextractException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
    return "";
}
Also used : FeatureType(software.amazon.awssdk.services.textract.model.FeatureType) DocumentLocation(software.amazon.awssdk.services.textract.model.DocumentLocation) StartDocumentAnalysisRequest(software.amazon.awssdk.services.textract.model.StartDocumentAnalysisRequest) TextractException(software.amazon.awssdk.services.textract.model.TextractException) ArrayList(java.util.ArrayList) S3Object(software.amazon.awssdk.services.textract.model.S3Object) StartDocumentAnalysisResponse(software.amazon.awssdk.services.textract.model.StartDocumentAnalysisResponse)

Aggregations

ArrayList (java.util.ArrayList)1 DocumentLocation (software.amazon.awssdk.services.textract.model.DocumentLocation)1 FeatureType (software.amazon.awssdk.services.textract.model.FeatureType)1 S3Object (software.amazon.awssdk.services.textract.model.S3Object)1 StartDocumentAnalysisRequest (software.amazon.awssdk.services.textract.model.StartDocumentAnalysisRequest)1 StartDocumentAnalysisResponse (software.amazon.awssdk.services.textract.model.StartDocumentAnalysisResponse)1 TextractException (software.amazon.awssdk.services.textract.model.TextractException)1