Skip to content

Commit 5e0dbda

Browse files
nnegreychingor13
authored andcommitted
samples: dialogflow: delete samples that are not in docs (#2602)
* dialogflow: delete samples that are not in docs and fix the tests that are broken after the deletions * update README
1 parent 9ae2109 commit 5e0dbda

18 files changed

+196
-1172
lines changed

dialogflow/snippets/src/main/java/com/example/dialogflow/ContextManagement.java

Lines changed: 0 additions & 131 deletions
This file was deleted.

dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentKnowledge.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import com.google.cloud.dialogflow.v2beta1.SessionName;
2929
import com.google.cloud.dialogflow.v2beta1.SessionsClient;
3030
import com.google.cloud.dialogflow.v2beta1.TextInput;
31-
import com.google.cloud.dialogflow.v2beta1.TextInput.Builder;
3231
import com.google.common.collect.Maps;
3332
import java.util.List;
3433
import java.util.Map;
@@ -67,7 +66,8 @@ public static Map<String, KnowledgeAnswers> detectIntentKnowledge(
6766
// Detect intents for each text input
6867
for (String text : texts) {
6968
// Set the text and language code (en-US) for the query
70-
Builder textInput = TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
69+
TextInput.Builder textInput =
70+
TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
7171
// Build the query with the TextInput
7272
QueryInput queryInput = QueryInput.newBuilder().setText(textInput).build();
7373

dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentTexts.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.google.cloud.dialogflow.v2.SessionName;
2525
import com.google.cloud.dialogflow.v2.SessionsClient;
2626
import com.google.cloud.dialogflow.v2.TextInput;
27-
import com.google.cloud.dialogflow.v2.TextInput.Builder;
2827
import com.google.common.collect.Maps;
2928
import java.util.List;
3029
import java.util.Map;
@@ -61,7 +60,8 @@ public static Map<String, QueryResult> detectIntentTexts(
6160
// Detect intents for each text input
6261
for (String text : texts) {
6362
// Set the text (hello) and language code (en-US) for the query
64-
Builder textInput = TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
63+
TextInput.Builder textInput =
64+
TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
6565

6666
// Build the query with the TextInput
6767
QueryInput queryInput = QueryInput.newBuilder().setText(textInput).build();

dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithModelSelection.java

Lines changed: 0 additions & 100 deletions
This file was deleted.

dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithSentimentAnalysis.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.google.cloud.dialogflow.v2.SessionName;
2626
import com.google.cloud.dialogflow.v2.SessionsClient;
2727
import com.google.cloud.dialogflow.v2.TextInput;
28-
import com.google.cloud.dialogflow.v2.TextInput.Builder;
2928
import com.google.common.collect.Maps;
3029
import java.util.List;
3130
import java.util.Map;
@@ -59,7 +58,8 @@ public static Map<String, QueryResult> detectIntentSentimentAnalysis(
5958
// Detect intents for each text input
6059
for (String text : texts) {
6160
// Set the text (hello) and language code (en-US) for the query
62-
Builder textInput = TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
61+
TextInput.Builder textInput =
62+
TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
6363

6464
// Build the query with the TextInput
6565
QueryInput queryInput = QueryInput.newBuilder().setText(textInput).build();

dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithTextToSpeechResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.google.cloud.dialogflow.v2.SessionName;
2626
import com.google.cloud.dialogflow.v2.SessionsClient;
2727
import com.google.cloud.dialogflow.v2.TextInput;
28-
import com.google.cloud.dialogflow.v2.TextInput.Builder;
2928
import com.google.common.collect.Maps;
3029
import java.util.List;
3130
import java.util.Map;
@@ -59,7 +58,8 @@ public static Map<String, QueryResult> detectIntentWithTexttoSpeech(
5958
// Detect intents for each text input
6059
for (String text : texts) {
6160
// Set the text (hello) and language code (en-US) for the query
62-
Builder textInput = TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
61+
TextInput.Builder textInput =
62+
TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
6363

6464
// Build the query with the TextInput
6565
QueryInput queryInput = QueryInput.newBuilder().setText(textInput).build();

dialogflow/snippets/src/main/java/com/example/dialogflow/DocumentManagement.java

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,9 @@
2222
import com.google.cloud.dialogflow.v2beta1.Document.KnowledgeType;
2323
import com.google.cloud.dialogflow.v2beta1.DocumentsClient;
2424
import com.google.cloud.dialogflow.v2beta1.KnowledgeOperationMetadata;
25-
import com.google.common.collect.Lists;
26-
import java.util.List;
2725
import java.util.concurrent.TimeUnit;
2826

2927
public class DocumentManagement {
30-
// [START dialogflow_list_document]
31-
32-
/**
33-
* @param knowledgeBaseName Knowledge Base id.
34-
*/
35-
public static List<Document> listDocuments(String knowledgeBaseName) throws Exception {
36-
List<Document> documents = Lists.newArrayList();
37-
// Instantiates a client
38-
try (DocumentsClient documentsClient = DocumentsClient.create()) {
39-
for (Document document : documentsClient.listDocuments(knowledgeBaseName).iterateAll()) {
40-
System.out.format(" - Display Name: %s\n", document.getDisplayName());
41-
System.out.format(" - Knowledge ID: %s\n", document.getName());
42-
System.out.format(" - MIME Type: %s\n", document.getMimeType());
43-
System.out.format(" - Knowledge Types:\n");
44-
for (KnowledgeType knowledgeTypeId : document.getKnowledgeTypesList()) {
45-
System.out.format(" - %s \n", knowledgeTypeId.getValueDescriptor());
46-
}
47-
System.out.format(" - Source: %s \n", document.getContentUri());
48-
49-
documents.add(document);
50-
}
51-
}
52-
return documents;
53-
}
54-
// [END dialogflow_list_document]
55-
5628
// [START dialogflow_create_document]
5729

5830
/**
@@ -100,42 +72,4 @@ public static Document createDocument(
10072
}
10173
}
10274
// [END dialogflow_create_document]
103-
104-
// [START dialogflow_get_document]
105-
106-
/**
107-
* @param documentName Document Id.
108-
* @return The requested document.
109-
*/
110-
public static Document getDocument(String documentName) throws Exception {
111-
// Instantiates a client
112-
try (DocumentsClient documentsClient = DocumentsClient.create()) {
113-
Document response = documentsClient.getDocument(documentName);
114-
System.out.format("Got Document: \n");
115-
System.out.format(" - Display Name: %s\n", response.getDisplayName());
116-
System.out.format(" - Knowledge ID: %s\n", response.getName());
117-
System.out.format(" - MIME Type: %s\n", response.getMimeType());
118-
System.out.format(" - Knowledge Types:\n");
119-
for (KnowledgeType knowledgeTypeId : response.getKnowledgeTypesList()) {
120-
System.out.format(" - %s \n", knowledgeTypeId.getValueDescriptor());
121-
}
122-
System.out.format(" - Source: %s \n", response.getContentUri());
123-
124-
return response;
125-
}
126-
}
127-
// [END dialogflow_get_document]
128-
129-
// [START dialogflow_delete_document]
130-
131-
/**
132-
* @param documentName Document Id.
133-
*/
134-
public static void deleteDocument(String documentName) throws Exception {
135-
// Instantiates a client
136-
try (DocumentsClient documentsClient = DocumentsClient.create()) {
137-
documentsClient.deleteDocumentAsync(documentName).get();
138-
System.out.format("The document has been deleted.");
139-
}
140-
}
14175
}

0 commit comments

Comments
 (0)