Search in sources :

Example 1 with Sentiment

use of com.google.cloud.language.v1beta2.Sentiment in project java-docs-samples by GoogleCloudPlatform.

the class AnalyzeBetaIT method analyzeSentiment_returnPositiveGerman.

@Test
public void analyzeSentiment_returnPositiveGerman() throws Exception {
    Sentiment sentiment = AnalyzeBeta.analyzeSentimentText("Ich hatte die schönste Erfahrung mit euch allen.", "DE");
    assertThat(sentiment.getMagnitude()).isGreaterThan(0.0F);
    assertThat(sentiment.getScore()).isGreaterThan(0.0F);
}
Also used : Sentiment(com.google.cloud.language.v1beta2.Sentiment) Test(org.junit.Test)

Example 2 with Sentiment

use of com.google.cloud.language.v1beta2.Sentiment in project java-docs-samples by GoogleCloudPlatform.

the class AnalyzeIT method analyzeSentimentFile_returnPositiveFile.

@Test
public void analyzeSentimentFile_returnPositiveFile() throws Exception {
    Sentiment sentiment = Analyze.analyzeSentimentFile("gs://" + BUCKET + "/natural-language/" + "sentiment/bladerunner-pos.txt");
    assertThat(sentiment.getMagnitude()).isGreaterThan(0.0F);
    assertThat(sentiment.getScore()).isGreaterThan(0.0F);
}
Also used : Sentiment(com.google.cloud.language.v1.Sentiment) Test(org.junit.Test)

Example 3 with Sentiment

use of com.google.cloud.language.v1beta2.Sentiment in project java-docs-samples by GoogleCloudPlatform.

the class AnalyzeIT method analyzeSentiment_returnNeutralFile.

@Test
public void analyzeSentiment_returnNeutralFile() throws Exception {
    Sentiment sentiment = Analyze.analyzeSentimentFile("gs://" + BUCKET + "/natural-language/" + "sentiment/bladerunner-neutral.txt");
    assertThat(sentiment.getMagnitude()).isGreaterThan(1.0F);
// TODO sentiment score for netural sample appears to be zero now.
// assertThat((double)sentiment.getScore()).isGreaterThan(0.0);
}
Also used : Sentiment(com.google.cloud.language.v1.Sentiment) Test(org.junit.Test)

Example 4 with Sentiment

use of com.google.cloud.language.v1beta2.Sentiment in project java-docs-samples by GoogleCloudPlatform.

the class AnalyzeIT method analyzeSentiment_returnNegative.

@Test
public void analyzeSentiment_returnNegative() throws Exception {
    Sentiment sentiment = Analyze.analyzeSentimentFile("gs://" + BUCKET + "/natural-language/" + "sentiment/bladerunner-neg.txt");
    assertThat(sentiment.getMagnitude()).isGreaterThan(0.0F);
    assertThat(sentiment.getScore()).isLessThan(0.0F);
}
Also used : Sentiment(com.google.cloud.language.v1.Sentiment) Test(org.junit.Test)

Example 5 with Sentiment

use of com.google.cloud.language.v1beta2.Sentiment in project java-docs-samples by GoogleCloudPlatform.

the class AnalyzeIT method analyzeSentimentText_returnPositive.

@Test
public void analyzeSentimentText_returnPositive() throws Exception {
    Sentiment sentiment = Analyze.analyzeSentimentText("Tom Cruise is one of the finest actors in hollywood and a great star!");
    assertThat(sentiment.getMagnitude()).isGreaterThan(0.0F);
    assertThat(sentiment.getScore()).isGreaterThan(0.0F);
}
Also used : Sentiment(com.google.cloud.language.v1.Sentiment) Test(org.junit.Test)

Aggregations

Sentiment (com.google.cloud.language.v1.Sentiment)9 Test (org.junit.Test)6 Document (com.google.cloud.language.v1.Document)4 LanguageServiceClient (com.google.cloud.language.v1.LanguageServiceClient)3 AnalyzeSentimentResponse (com.google.cloud.language.v1.AnalyzeSentimentResponse)2 Sentiment (com.google.cloud.language.v1beta2.Sentiment)2 LanguageServiceClient (com.google.cloud.language.spi.v1.LanguageServiceClient)1 AnalyzeSentimentResponse (com.google.cloud.language.v1beta2.AnalyzeSentimentResponse)1 Document (com.google.cloud.language.v1beta2.Document)1 LanguageServiceClient (com.google.cloud.language.v1beta2.LanguageServiceClient)1