Search in sources :

Example 1 with ComprehendClient

use of software.amazon.awssdk.services.comprehend.ComprehendClient in project aws-doc-sdk-examples by awsdocs.

the class DetectKeyPhrases method main.

public static void main(String[] args) {
    String text = "Amazon.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.";
    Region region = Region.US_EAST_1;
    ComprehendClient comClient = ComprehendClient.builder().region(region).build();
    System.out.println("Calling DetectKeyPhrases");
    detectAllKeyPhrases(comClient, text);
    comClient.close();
}
Also used : ComprehendClient(software.amazon.awssdk.services.comprehend.ComprehendClient) Region(software.amazon.awssdk.regions.Region)

Example 2 with ComprehendClient

use of software.amazon.awssdk.services.comprehend.ComprehendClient in project aws-doc-sdk-examples by awsdocs.

the class DetectSentiment method main.

public static void main(String[] args) {
    String text = "Amazon.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.";
    Region region = Region.US_EAST_1;
    ComprehendClient comClient = ComprehendClient.builder().region(region).build();
    System.out.println("Calling DetectSentiment");
    detectSentiments(comClient, text);
    comClient.close();
}
Also used : ComprehendClient(software.amazon.awssdk.services.comprehend.ComprehendClient) Region(software.amazon.awssdk.regions.Region)

Example 3 with ComprehendClient

use of software.amazon.awssdk.services.comprehend.ComprehendClient in project aws-doc-sdk-examples by awsdocs.

the class DetectLanguage method main.

public static void main(String[] args) {
    // Specify French text - "It is raining today in Seattle"
    String text = "Il pleut aujourd'hui à Seattle";
    Region region = Region.US_EAST_1;
    ComprehendClient comClient = ComprehendClient.builder().region(region).build();
    System.out.println("Calling DetectDominantLanguage");
    detectTheDominantLanguage(comClient, text);
    comClient.close();
}
Also used : ComprehendClient(software.amazon.awssdk.services.comprehend.ComprehendClient) Region(software.amazon.awssdk.regions.Region)

Example 4 with ComprehendClient

use of software.amazon.awssdk.services.comprehend.ComprehendClient in project aws-doc-sdk-examples by awsdocs.

the class DetectSyntax method main.

public static void main(String[] args) {
    String text = "Amazon.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.";
    Region region = Region.US_EAST_1;
    ComprehendClient comClient = ComprehendClient.builder().region(region).build();
    System.out.println("Calling DetectSyntax");
    detectAllSyntax(comClient, text);
    comClient.close();
}
Also used : ComprehendClient(software.amazon.awssdk.services.comprehend.ComprehendClient) Region(software.amazon.awssdk.regions.Region)

Example 5 with ComprehendClient

use of software.amazon.awssdk.services.comprehend.ComprehendClient in project aws-doc-sdk-examples by awsdocs.

the class LexService method DetectLanguage.

private String DetectLanguage(String text) {
    Region region = Region.US_EAST_1;
    ComprehendClient comClient = ComprehendClient.builder().region(region).build();
    try {
        String lanCode = "";
        DetectDominantLanguageRequest request = DetectDominantLanguageRequest.builder().text(text).build();
        DetectDominantLanguageResponse resp = comClient.detectDominantLanguage(request);
        List<DominantLanguage> allLanList = resp.languages();
        Iterator<DominantLanguage> lanIterator = allLanList.iterator();
        while (lanIterator.hasNext()) {
            DominantLanguage lang = lanIterator.next();
            lanCode = lang.languageCode();
        }
        return lanCode;
    } catch (ComprehendException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
    return "";
}
Also used : ComprehendException(software.amazon.awssdk.services.comprehend.model.ComprehendException) DominantLanguage(software.amazon.awssdk.services.comprehend.model.DominantLanguage) DetectDominantLanguageResponse(software.amazon.awssdk.services.comprehend.model.DetectDominantLanguageResponse) ComprehendClient(software.amazon.awssdk.services.comprehend.ComprehendClient) DetectDominantLanguageRequest(software.amazon.awssdk.services.comprehend.model.DetectDominantLanguageRequest) Region(software.amazon.awssdk.regions.Region)

Aggregations

Region (software.amazon.awssdk.regions.Region)7 ComprehendClient (software.amazon.awssdk.services.comprehend.ComprehendClient)7 ComprehendException (software.amazon.awssdk.services.comprehend.model.ComprehendException)1 DetectDominantLanguageRequest (software.amazon.awssdk.services.comprehend.model.DetectDominantLanguageRequest)1 DetectDominantLanguageResponse (software.amazon.awssdk.services.comprehend.model.DetectDominantLanguageResponse)1 DominantLanguage (software.amazon.awssdk.services.comprehend.model.DominantLanguage)1