@@ -0,0 +1,3205 @@
+// snippet-sourcedescription:%5BDetectSyntax demonstrates how to detect syntax in the text.%5D%0A// snippet-service:%5BAmazon Comprehend%5D%0A// snippet-keyword:%5BJava%5D%0A// snippet-sourcesyntax:%5Bjava%5D%0A// snippet-keyword:%5BAmazon Comprehend%5D%0A// snippet-keyword:%5BCode Sample%5D%0A// snippet-sourcetype:%5Bfull-example%5D%0A// snippet-sourcedate:%5B6/3/2020%5D%0A// snippet-sourceauthor:%5Bscmacdon AWS%5D%0A%0A%0A/**%0A * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A *%0A * This file is licensed under the Apache License, Version 2.0 (the %22License%22).%0A * You may not use this file except in compliance with the License. A copy of%0A * the License is located at%0A *%0A * http://aws.amazon.com/apache2.0/%0A *%0A * This file is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR%0A * CONDITIONS OF ANY KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations under the License.%0A */%0Apackage com.example.comprehend;%0A%0A//snippet-start:%5Bcomprehend.java2.detect_syntax.import%5D%0Aimport software.amazon.awssdk.regions.Region;%0Aimport software.amazon.awssdk.services.comprehend.ComprehendClient;%0Aimport software.amazon.awssdk.services.comprehend.model.ComprehendException;%0Aimport software.amazon.awssdk.services.comprehend.model.DetectSyntaxRequest;%0Aimport software.amazon.awssdk.services.comprehend.model.DetectSyntaxResponse;%0Aimport software.amazon.awssdk.services.comprehend.model.SyntaxToken;%0Aimport java.util.Iterator;%0Aimport java.util.List;%0A//snippet-end:%5Bcomprehend.java2.detect_syntax.import%5D%0A%0A%0Apublic class DetectSyntax %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        String text = %22Amazon.com, Inc. is located in Seattle, WA and was founded July 5th, 1994 by Jeff Bezos, allowing customers to buy everything from books to blenders. Seattle is north of Portland and south of Vancouver, BC. Other notable Seattle - based companies are Starbucks and Boeing.%22;%0A        Region region = Region.US_EAST_1;%0A        ComprehendClient comClient = ComprehendClient.builder()%0A                .region(region)%0A                .build();%0A%0A        System.out.println(%22Calling DetectSyntax%22);%0A        detectAllSyntax(comClient, text);%0A    %7D%0A%0A    //snippet-start:%5Bcomprehend.java2.detect_syntax.main%5D%0A    public static void detectAllSyntax(ComprehendClient comClient, String text)%7B%0A%0A        try %7B%0A            DetectSyntaxRequest detectSyntaxRequest = DetectSyntaxRequest.builder()%0A                .text(text)%0A                .languageCode(%22en%22)%0A                .build();%0A%0A        DetectSyntaxResponse detectSyntaxResult = comClient.detectSyntax(detectSyntaxRequest);%0A        List%3CSyntaxToken%3E syntaxTokens = detectSyntaxResult.syntaxTokens();%0A        Iterator%3CSyntaxToken%3E syntaxIterator = syntaxTokens.iterator();%0A%0A        while(syntaxIterator.hasNext()) %7B%0A            SyntaxToken token = syntaxIterator.next();%0A            System.out.println(%22Language is %22 +token.text());%0A            System.out.println(%22Part of speech is %22+ token.partOfSpeech().tagAsString());%0A        %7D%0A%0A        %7D catch (ComprehendException e) %7B%0A            System.err.println(e.awsErrorDetails().errorMessage());%0A            System.exit(1);%0A        %7D%0A        //snippet-end:%5Bcomprehend.java2.detect_syntax.main%5D%0A    %7D%0A%7D%0A

Create DetectSyntax.java