/* * Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.comprehend.model; import java.io.Serializable; /** *
* Information about one mention of an entity. The mention information includes * the location of the mention in the text and the sentiment of the mention. *
** For more information about targeted sentiment, see Targeted sentiment. *
*/ public class TargetedSentimentMention implements Serializable { /** ** Model confidence that the entity is relevant. Value range is zero to one, * where one is highest confidence. *
*/ private Float score; /** ** The confidence that all the entities mentioned in the group relate to the * same entity. *
*/ private Float groupScore; /** ** The text in the document that identifies the entity. *
*
* Constraints:
* Length: 1 -
*/
private String text;
/**
*
* The type of the entity. Amazon Comprehend supports a variety of entity types. *
*
* Constraints:
* Allowed Values: PERSON, LOCATION, ORGANIZATION, FACILITY, BRAND,
* COMMERCIAL_ITEM, MOVIE, MUSIC, BOOK, SOFTWARE, GAME, PERSONAL_TITLE,
* EVENT, DATE, QUANTITY, ATTRIBUTE, OTHER
*/
private String type;
/**
*
* Contains the sentiment and sentiment score for the mention. *
*/ private MentionSentiment mentionSentiment; /** ** The offset into the document text where the mention begins. *
*/ private Integer beginOffset; /** ** The offset into the document text where the mention ends. *
*/ private Integer endOffset; /** ** Model confidence that the entity is relevant. Value range is zero to one, * where one is highest confidence. *
* * @return* Model confidence that the entity is relevant. Value range is zero * to one, where one is highest confidence. *
*/ public Float getScore() { return score; } /** ** Model confidence that the entity is relevant. Value range is zero to one, * where one is highest confidence. *
* * @param score* Model confidence that the entity is relevant. Value range is * zero to one, where one is highest confidence. *
*/ public void setScore(Float score) { this.score = score; } /** ** Model confidence that the entity is relevant. Value range is zero to one, * where one is highest confidence. *
** Returns a reference to this object so that method calls can be chained * together. * * @param score
* Model confidence that the entity is relevant. Value range is * zero to one, where one is highest confidence. *
* @return A reference to this updated object so that method calls can be * chained together. */ public TargetedSentimentMention withScore(Float score) { this.score = score; return this; } /** ** The confidence that all the entities mentioned in the group relate to the * same entity. *
* * @return* The confidence that all the entities mentioned in the group * relate to the same entity. *
*/ public Float getGroupScore() { return groupScore; } /** ** The confidence that all the entities mentioned in the group relate to the * same entity. *
* * @param groupScore* The confidence that all the entities mentioned in the group * relate to the same entity. *
*/ public void setGroupScore(Float groupScore) { this.groupScore = groupScore; } /** ** The confidence that all the entities mentioned in the group relate to the * same entity. *
** Returns a reference to this object so that method calls can be chained * together. * * @param groupScore
* The confidence that all the entities mentioned in the group * relate to the same entity. *
* @return A reference to this updated object so that method calls can be * chained together. */ public TargetedSentimentMention withGroupScore(Float groupScore) { this.groupScore = groupScore; return this; } /** ** The text in the document that identifies the entity. *
*
* Constraints:
* Length: 1 -
*
* @return
* The text in the document that identifies the entity. *
*/ public String getText() { return text; } /** ** The text in the document that identifies the entity. *
*
* Constraints:
* Length: 1 -
*
* @param text
* The text in the document that identifies the entity. *
*/ public void setText(String text) { this.text = text; } /** ** The text in the document that identifies the entity. *
** Returns a reference to this object so that method calls can be chained * together. *
* Constraints:
* Length: 1 -
*
* @param text
* The text in the document that identifies the entity. *
* @return A reference to this updated object so that method calls can be * chained together. */ public TargetedSentimentMention withText(String text) { this.text = text; return this; } /** ** The type of the entity. Amazon Comprehend supports a variety of entity types. *
*
* Constraints:
* Allowed Values: PERSON, LOCATION, ORGANIZATION, FACILITY, BRAND,
* COMMERCIAL_ITEM, MOVIE, MUSIC, BOOK, SOFTWARE, GAME, PERSONAL_TITLE,
* EVENT, DATE, QUANTITY, ATTRIBUTE, OTHER
*
* @return
* The type of the entity. Amazon Comprehend supports a variety of * entity types. *
* @see TargetedSentimentEntityType */ public String getType() { return type; } /** ** The type of the entity. Amazon Comprehend supports a variety of entity types. *
*
* Constraints:
* Allowed Values: PERSON, LOCATION, ORGANIZATION, FACILITY, BRAND,
* COMMERCIAL_ITEM, MOVIE, MUSIC, BOOK, SOFTWARE, GAME, PERSONAL_TITLE,
* EVENT, DATE, QUANTITY, ATTRIBUTE, OTHER
*
* @param type
* The type of the entity. Amazon Comprehend supports a variety * of entity types. *
* @see TargetedSentimentEntityType */ public void setType(String type) { this.type = type; } /** ** The type of the entity. Amazon Comprehend supports a variety of entity types. *
** Returns a reference to this object so that method calls can be chained * together. *
* Constraints:
* Allowed Values: PERSON, LOCATION, ORGANIZATION, FACILITY, BRAND,
* COMMERCIAL_ITEM, MOVIE, MUSIC, BOOK, SOFTWARE, GAME, PERSONAL_TITLE,
* EVENT, DATE, QUANTITY, ATTRIBUTE, OTHER
*
* @param type
* The type of the entity. Amazon Comprehend supports a variety * of entity types. *
* @return A reference to this updated object so that method calls can be * chained together. * @see TargetedSentimentEntityType */ public TargetedSentimentMention withType(String type) { this.type = type; return this; } /** ** The type of the entity. Amazon Comprehend supports a variety of entity types. *
*
* Constraints:
* Allowed Values: PERSON, LOCATION, ORGANIZATION, FACILITY, BRAND,
* COMMERCIAL_ITEM, MOVIE, MUSIC, BOOK, SOFTWARE, GAME, PERSONAL_TITLE,
* EVENT, DATE, QUANTITY, ATTRIBUTE, OTHER
*
* @param type
* The type of the entity. Amazon Comprehend supports a variety * of entity types. *
* @see TargetedSentimentEntityType */ public void setType(TargetedSentimentEntityType type) { this.type = type.toString(); } /** ** The type of the entity. Amazon Comprehend supports a variety of entity types. *
** Returns a reference to this object so that method calls can be chained * together. *
* Constraints:
* Allowed Values: PERSON, LOCATION, ORGANIZATION, FACILITY, BRAND,
* COMMERCIAL_ITEM, MOVIE, MUSIC, BOOK, SOFTWARE, GAME, PERSONAL_TITLE,
* EVENT, DATE, QUANTITY, ATTRIBUTE, OTHER
*
* @param type
* The type of the entity. Amazon Comprehend supports a variety * of entity types. *
* @return A reference to this updated object so that method calls can be * chained together. * @see TargetedSentimentEntityType */ public TargetedSentimentMention withType(TargetedSentimentEntityType type) { this.type = type.toString(); return this; } /** ** Contains the sentiment and sentiment score for the mention. *
* * @return* Contains the sentiment and sentiment score for the mention. *
*/ public MentionSentiment getMentionSentiment() { return mentionSentiment; } /** ** Contains the sentiment and sentiment score for the mention. *
* * @param mentionSentiment* Contains the sentiment and sentiment score for the mention. *
*/ public void setMentionSentiment(MentionSentiment mentionSentiment) { this.mentionSentiment = mentionSentiment; } /** ** Contains the sentiment and sentiment score for the mention. *
** Returns a reference to this object so that method calls can be chained * together. * * @param mentionSentiment
* Contains the sentiment and sentiment score for the mention. *
* @return A reference to this updated object so that method calls can be * chained together. */ public TargetedSentimentMention withMentionSentiment(MentionSentiment mentionSentiment) { this.mentionSentiment = mentionSentiment; return this; } /** ** The offset into the document text where the mention begins. *
* * @return* The offset into the document text where the mention begins. *
*/ public Integer getBeginOffset() { return beginOffset; } /** ** The offset into the document text where the mention begins. *
* * @param beginOffset* The offset into the document text where the mention begins. *
*/ public void setBeginOffset(Integer beginOffset) { this.beginOffset = beginOffset; } /** ** The offset into the document text where the mention begins. *
** Returns a reference to this object so that method calls can be chained * together. * * @param beginOffset
* The offset into the document text where the mention begins. *
* @return A reference to this updated object so that method calls can be * chained together. */ public TargetedSentimentMention withBeginOffset(Integer beginOffset) { this.beginOffset = beginOffset; return this; } /** ** The offset into the document text where the mention ends. *
* * @return* The offset into the document text where the mention ends. *
*/ public Integer getEndOffset() { return endOffset; } /** ** The offset into the document text where the mention ends. *
* * @param endOffset* The offset into the document text where the mention ends. *
*/ public void setEndOffset(Integer endOffset) { this.endOffset = endOffset; } /** ** The offset into the document text where the mention ends. *
** Returns a reference to this object so that method calls can be chained * together. * * @param endOffset
* The offset into the document text where the mention ends. *
* @return A reference to this updated object so that method calls can be * chained together. */ public TargetedSentimentMention withEndOffset(Integer endOffset) { this.endOffset = endOffset; return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getScore() != null) sb.append("Score: " + getScore() + ","); if (getGroupScore() != null) sb.append("GroupScore: " + getGroupScore() + ","); if (getText() != null) sb.append("Text: " + getText() + ","); if (getType() != null) sb.append("Type: " + getType() + ","); if (getMentionSentiment() != null) sb.append("MentionSentiment: " + getMentionSentiment() + ","); if (getBeginOffset() != null) sb.append("BeginOffset: " + getBeginOffset() + ","); if (getEndOffset() != null) sb.append("EndOffset: " + getEndOffset()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getScore() == null) ? 0 : getScore().hashCode()); hashCode = prime * hashCode + ((getGroupScore() == null) ? 0 : getGroupScore().hashCode()); hashCode = prime * hashCode + ((getText() == null) ? 0 : getText().hashCode()); hashCode = prime * hashCode + ((getType() == null) ? 0 : getType().hashCode()); hashCode = prime * hashCode + ((getMentionSentiment() == null) ? 0 : getMentionSentiment().hashCode()); hashCode = prime * hashCode + ((getBeginOffset() == null) ? 0 : getBeginOffset().hashCode()); hashCode = prime * hashCode + ((getEndOffset() == null) ? 0 : getEndOffset().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof TargetedSentimentMention == false) return false; TargetedSentimentMention other = (TargetedSentimentMention) obj; if (other.getScore() == null ^ this.getScore() == null) return false; if (other.getScore() != null && other.getScore().equals(this.getScore()) == false) return false; if (other.getGroupScore() == null ^ this.getGroupScore() == null) return false; if (other.getGroupScore() != null && other.getGroupScore().equals(this.getGroupScore()) == false) return false; if (other.getText() == null ^ this.getText() == null) return false; if (other.getText() != null && other.getText().equals(this.getText()) == false) return false; if (other.getType() == null ^ this.getType() == null) return false; if (other.getType() != null && other.getType().equals(this.getType()) == false) return false; if (other.getMentionSentiment() == null ^ this.getMentionSentiment() == null) return false; if (other.getMentionSentiment() != null && other.getMentionSentiment().equals(this.getMentionSentiment()) == false) return false; if (other.getBeginOffset() == null ^ this.getBeginOffset() == null) return false; if (other.getBeginOffset() != null && other.getBeginOffset().equals(this.getBeginOffset()) == false) return false; if (other.getEndOffset() == null ^ this.getEndOffset() == null) return false; if (other.getEndOffset() != null && other.getEndOffset().equals(this.getEndOffset()) == false) return false; return true; } }