Skip to content

Commit b09f9fd

Browse files
authored
Merge pull request GoogleCloudPlatform#667 from GoogleCloudPlatform/language-encoding-test
Adds test for encoded characters.
2 parents 9dd1fbe + 8391dd6 commit b09f9fd

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

language/analysis/src/main/java/com/google/cloud/language/samples/Analyze.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public static void printSyntax(PrintStream out, List<Token> tokens) {
138138
out.printf("\tBeginOffset: %d\n", token.getText().getBeginOffset());
139139
out.printf("Lemma: %s\n", token.getLemma());
140140
out.printf("PartOfSpeechTag: %s\n", token.getPartOfSpeech().getTag());
141-
out.printf("\tAspect: %s\n",token.getPartOfSpeech().getAspect());
141+
out.printf("\tAspect: %s\n", token.getPartOfSpeech().getAspect());
142142
out.printf("\tCase: %s\n", token.getPartOfSpeech().getCase());
143143
out.printf("\tForm: %s\n", token.getPartOfSpeech().getForm());
144144
out.printf("\tGender: %s\n",token.getPartOfSpeech().getGender());

language/analysis/src/test/java/com/google/cloud/language/samples/AnalyzeBetaIT.java

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.google.cloud.language.spi.v1beta2.LanguageServiceClient;
2222
import com.google.cloud.language.v1beta2.Entity;
23+
import com.google.cloud.language.v1beta2.EntityMention;
2324
import com.google.cloud.language.v1beta2.Sentiment;
2425

2526
import org.junit.Before;
@@ -66,6 +67,15 @@ public class AnalyzeBetaIT {
6667
assertThat(got).named("entity names").contains("Seattle");
6768
}
6869

70+
@Test public void analyzeSyntax_entitySentimentTextEncoded() throws Exception {
71+
List<Entity> entities = analyzeApp.entitySentimentText("foo→bar");
72+
73+
List<EntityMention> mentions = entities.listIterator().next().getMentionsList();
74+
75+
// Assert
76+
assertThat(mentions.get(0).getText().getBeginOffset() == 4);
77+
}
78+
6979
@Test public void analyzeSyntax_entitySentimentFile() throws Exception {
7080
List<Entity> entities =
7181
analyzeApp.entitySentimentFile("gs://" + BUCKET + "/natural-language/gettysburg.txt");

0 commit comments

Comments
 (0)