@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.language.v1.ClassificationCategory)) { return super.equals(obj); } com.google.cloud.language.v1.ClassificationCategory other = (com.google.cloud.language.v1.ClassificationCategory) obj; boolean result = true; result = result && getName().equals(other.getName()); result = result && (java.lang.Float.floatToIntBits(getConfidence()) == java.lang.Float.floatToIntBits(other.getConfidence())); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public com.google.cloud.language.v1.ClassificationCategory buildPartial() { com.google.cloud.language.v1.ClassificationCategory result = new com.google.cloud.language.v1.ClassificationCategory(this); result.name_ = name_; result.confidence_ = confidence_; onBuilt(); return result; }
public Builder mergeFrom(com.google.cloud.language.v1.ClassificationCategory other) { if (other == com.google.cloud.language.v1.ClassificationCategory.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (other.getConfidence() != 0F) { setConfidence(other.getConfidence()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + CONFIDENCE_FIELD_NUMBER; hash = (53 * hash) + java.lang.Float.floatToIntBits(getConfidence()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The name of the category representing the document. * </pre> * * <code>string name = 1;</code> */ public Builder clearName() { name_ = getDefaultInstance().getName(); onChanged(); return this; } /**
@java.lang.Override public com.google.cloud.language.v1.ClassificationCategory getDefaultInstanceForType() { return com.google.cloud.language.v1.ClassificationCategory.getDefaultInstance(); }
if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { done = true; } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable();
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getNameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); } if (confidence_ != 0F) { output.writeFloat(2, confidence_); } unknownFields.writeTo(output); }
@java.lang.Override public com.google.cloud.language.v1.ClassificationCategory build() { com.google.cloud.language.v1.ClassificationCategory result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + CONFIDENCE_FIELD_NUMBER; hash = (53 * hash) + java.lang.Float.floatToIntBits(getConfidence()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The name of the category representing the document. * </pre> * * <code>string name = 1;</code> */ public Builder clearName() { name_ = getDefaultInstance().getName(); onChanged(); return this; } /**
/** * * * <pre> * Categories identified in the input document. * </pre> * * <code>repeated .google.cloud.language.v1.ClassificationCategory categories = 6;</code> */ public com.google.cloud.language.v1.ClassificationCategory.Builder addCategoriesBuilder() { return getCategoriesFieldBuilder() .addBuilder(com.google.cloud.language.v1.ClassificationCategory.getDefaultInstance()); } /**
if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { done = true; } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable();
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getNameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); } if (confidence_ != 0F) { size += com.google.protobuf.CodedOutputStream.computeFloatSize(2, confidence_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@java.lang.Override public com.google.cloud.language.v1.ClassificationCategory build() { com.google.cloud.language.v1.ClassificationCategory result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
/** * Detects categories in text using the Language Beta API. */ public static void classifyText(String text) throws Exception { // [START language_classify_text] // Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient try (LanguageServiceClient language = LanguageServiceClient.create()) { // set content to the text string Document doc = Document.newBuilder() .setContent(text) .setType(Type.PLAIN_TEXT) .build(); ClassifyTextRequest request = ClassifyTextRequest.newBuilder() .setDocument(doc) .build(); // detect categories in the given text ClassifyTextResponse response = language.classifyText(request); for (ClassificationCategory category : response.getCategoriesList()) { System.out.printf("Category name : %s, Confidence : %.3f\n", category.getName(), category.getConfidence()); } } // [END language_classify_text] }
public Builder mergeFrom(com.google.cloud.language.v1.ClassificationCategory other) { if (other == com.google.cloud.language.v1.ClassificationCategory.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (other.getConfidence() != 0F) { setConfidence(other.getConfidence()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** * * * <pre> * Categories representing the input document. * </pre> * * <code>repeated .google.cloud.language.v1.ClassificationCategory categories = 1;</code> */ public com.google.cloud.language.v1.ClassificationCategory.Builder addCategoriesBuilder() { return getCategoriesFieldBuilder() .addBuilder(com.google.cloud.language.v1.ClassificationCategory.getDefaultInstance()); } /**