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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations