@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.language.v1.ClassifyTextResponse)) { return super.equals(obj); } com.google.cloud.language.v1.ClassifyTextResponse other = (com.google.cloud.language.v1.ClassifyTextResponse) obj; boolean result = true; result = result && getCategoriesList().equals(other.getCategoriesList()); 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(); if (getCategoriesCount() > 0) { hash = (37 * hash) + CATEGORIES_FIELD_NUMBER; hash = (53 * hash) + getCategoriesList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * 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] }
/** * Detects categories in a GCS hosted file using the Language Beta API. */ public static void classifyFile(String gcsUri) throws Exception { // [START language_classify_gcs] // Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient try (LanguageServiceClient language = LanguageServiceClient.create()) { // set the GCS content URI path Document doc = Document.newBuilder() .setGcsContentUri(gcsUri) .setType(Type.PLAIN_TEXT) .build(); ClassifyTextRequest request = ClassifyTextRequest.newBuilder() .setDocument(doc) .build(); // detect categories in the given file 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_gcs] }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.language.v1.ClassifyTextResponse)) { return super.equals(obj); } com.google.cloud.language.v1.ClassifyTextResponse other = (com.google.cloud.language.v1.ClassifyTextResponse) obj; boolean result = true; result = result && getCategoriesList().equals(other.getCategoriesList()); 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(); if (getCategoriesCount() > 0) { hash = (37 * hash) + CATEGORIES_FIELD_NUMBER; hash = (53 * hash) + getCategoriesList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }