2019-08-27 16:25:01 -07:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
2024-01-16 10:41:11 -05:00
2019-08-27 16:25:01 -07:00
/**
* COPYRIGHT:
*
* Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
// snippet-start:[comprehend-medical.java-detect-entities]
import com.amazonaws.auth.AWSCredentials ;
import com.amazonaws.auth.AWSCredentialsProvider ;
import com.amazonaws.auth.AWSStaticCredentialsProvider ;
import com.amazonaws.auth.BasicAWSCredentials ;
import com.amazonaws.client.builder.AwsClientBuilder ;
import com.amazonaws.services.comprehendmedical.AWSComprehendMedical ;
import com.amazonaws.services.comprehendmedical.AWSComprehendMedicalClient ;
import com.amazonaws.services.comprehendmedical.model.DetectEntitiesRequest ;
import com.amazonaws.services.comprehendmedical.model.DetectEntitiesResult ;
2024-01-16 10:41:11 -05:00
2019-08-27 16:25:01 -07:00
public class SampleAPICall {
2024-01-16 10:41:11 -05:00
2019-08-27 16:25:01 -07:00
public static void main ( ) {
2024-01-16 10:41:11 -05:00
2019-08-27 16:25:01 -07:00
AWSCredentialsProvider credentials = new AWSStaticCredentialsProvider (
new BasicAWSCredentials ( " YOUR AWS ACCESS KEY " , " YOUR AWS SECRET " ) ) ;
2024-01-16 10:41:11 -05:00
2019-08-27 16:25:01 -07:00
AWSComprehendMedical client = AWSComprehendMedicalClient . builder ( )
. withCredentials ( credentials )
. withRegion ( " YOUR REGION " )
. build ( ) ;
2024-01-16 10:41:11 -05:00
2019-08-27 16:25:01 -07:00
DetectEntitiesRequest request = new DetectEntitiesRequest ( ) ;
request . setText ( " cerealx 84 mg daily " ) ;
2024-01-16 10:41:11 -05:00
2019-08-27 16:25:01 -07:00
DetectEntitiesResult result = client . detectEntities ( request ) ;
result . getEntities ( ) . forEach ( System . out : : println ) ;
}
}
2019-01-10 17:07:29 +00:00
// snippet-end:[comprehend-medical.java-detect-entities]