@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.language.v1.TextSpan)) { return super.equals(obj); } com.google.cloud.language.v1.TextSpan other = (com.google.cloud.language.v1.TextSpan) obj; boolean result = true; result = result && getContent().equals(other.getContent()); result = result && (getBeginOffset() == other.getBeginOffset()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + CONTENT_FIELD_NUMBER; hash = (53 * hash) + getContent().hashCode(); hash = (37 * hash) + BEGIN_OFFSET_FIELD_NUMBER; hash = (53 * hash) + getBeginOffset(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(com.google.cloud.language.v1.TextSpan other) { if (other == com.google.cloud.language.v1.TextSpan.getDefaultInstance()) return this; if (!other.getContent().isEmpty()) { content_ = other.content_; onChanged(); } if (other.getBeginOffset() != 0) { setBeginOffset(other.getBeginOffset()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
System.out.printf("Begin offset: %d\n", mention.getText().getBeginOffset()); System.out.printf("Content: %s\n", mention.getText().getContent()); System.out.printf("Type: %s\n\n", mention.getType());
System.out.printf("Begin offset: %d\n", mention.getText().getBeginOffset()); System.out.printf("Content: %s\n", mention.getText().getContent()); System.out.printf("Type: %s\n\n", mention.getType());
/** * Detects the entity sentiments in the string {@code text} using the Language Beta API. */ public static void entitySentimentText(String text) throws Exception { // [START language_entity_sentiment_text] // Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient try (LanguageServiceClient language = LanguageServiceClient.create()) { Document doc = Document.newBuilder() .setContent(text).setType(Type.PLAIN_TEXT).build(); AnalyzeEntitySentimentRequest request = AnalyzeEntitySentimentRequest.newBuilder() .setDocument(doc) .setEncodingType(EncodingType.UTF16).build(); // detect entity sentiments in the given string AnalyzeEntitySentimentResponse response = language.analyzeEntitySentiment(request); // Print the response for (Entity entity : response.getEntitiesList()) { System.out.printf("Entity: %s\n", entity.getName()); System.out.printf("Salience: %.3f\n", entity.getSalience()); System.out.printf("Sentiment : %s\n", entity.getSentiment()); for (EntityMention mention : entity.getMentionsList()) { System.out.printf("Begin offset: %d\n", mention.getText().getBeginOffset()); System.out.printf("Content: %s\n", mention.getText().getContent()); System.out.printf("Magnitude: %.3f\n", mention.getSentiment().getMagnitude()); System.out.printf("Sentiment score : %.3f\n", mention.getSentiment().getScore()); System.out.printf("Type: %s\n\n", mention.getType()); } } } // [END language_entity_sentiment_text] }
System.out.printf("Sentiment : %s\n", entity.getSentiment()); for (EntityMention mention : entity.getMentionsList()) { System.out.printf("Begin offset: %d\n", mention.getText().getBeginOffset()); System.out.printf("Content: %s\n", mention.getText().getContent()); System.out.printf("Magnitude: %.3f\n", mention.getSentiment().getMagnitude());
System.out.printf("\tBeginOffset: %d\n", token.getText().getBeginOffset()); System.out.printf("Lemma: %s\n", token.getLemma()); System.out.printf("PartOfSpeechTag: %s\n", token.getPartOfSpeech().getTag());
System.out.printf("\tBeginOffset: %d\n", token.getText().getBeginOffset()); System.out.printf("Lemma: %s\n", token.getLemma()); System.out.printf("PartOfSpeechTag: %s\n", token.getPartOfSpeech().getTag());
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.language.v1.TextSpan)) { return super.equals(obj); } com.google.cloud.language.v1.TextSpan other = (com.google.cloud.language.v1.TextSpan) obj; boolean result = true; result = result && getContent().equals(other.getContent()); result = result && (getBeginOffset() == other.getBeginOffset()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + CONTENT_FIELD_NUMBER; hash = (53 * hash) + getContent().hashCode(); hash = (37 * hash) + BEGIN_OFFSET_FIELD_NUMBER; hash = (53 * hash) + getBeginOffset(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(com.google.cloud.language.v1.TextSpan other) { if (other == com.google.cloud.language.v1.TextSpan.getDefaultInstance()) return this; if (!other.getContent().isEmpty()) { content_ = other.content_; onChanged(); } if (other.getBeginOffset() != 0) { setBeginOffset(other.getBeginOffset()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }