SubmitFeedback

This operation submits feedback to the specified knowledge base for the text comprised of the given field definitions. Positive feedback is submitted for each of the categories. The feedback is queued for processing offline.

To enrich history information necessary for tuning, analyzing, redesigning, and updating a knowledge base, use the SubmitFeedbackWithID operation instead of this operation.

Restriction: The SubmitFeedback operation was deprecated in IBM® Content Classification, Version 8.6. Use the SubmitFeedbackDocument operation instead of this operation.

Parameters

KB name
The name of the knowledge base.
NVPs
The array of field definitions (name-value pairs) that comprise the text.
Positive categories
An array of categories that received positive feedback.
Language name
The language of the text. Pass an empty string if the language is unknown. The language is set as follows:
  • If the language name is provided, the language is set to the specified language, unless it is not supported by the knowledge base. In this case, the feedback will not be processed.
  • If no language is provided and the knowledge base is monolingual, the knowledge base's language is used.
  • If no language is provided and the knowledge base is multilingual, a language identifier is used to determine the text's language. If the language identifier fails to identify the text's language, or identifies it as a language that is not supported by the knowledge base, the feedback will not be processed.
    Restriction: The language name is case-sensitive. For example: English is not the same as english. To view a list of supported languages, use the Management Console or the GetAllSupportedLanguages operation.

Remarks

This operation does not perform any validation of the text. According to the flow of your application, you might want to validate that the field definitions and categories exist before submitting the feedback.

Sample code: C

  1. // Acquire a connection from the pool
  2. bns__Connection connection = bns__acquire_connection(pool);
  3. // Allocate and populate the NVP array
  4. ArrayOfNVPs nvps;
  5. nvps.__size = 1;
  6. nvps.__ptrNVPs = (bns__NVP*) malloc (sizeof(bns__NVP));
  7. nvps.__ptrNVPs[0].Name = nvpName;
  8. nvps.__ptrNVPs[0].Value = text;
  9. // Pass an empty string as the language name.
  10. wchar_t* language = (wchar_t*)L"";
  11. // Allocate and populate the positive categories array
  12. ArrayOfWStrings positive_cats;
  13. positive_cats.__size = 1;
  14. positive_cats.__ptrStrings = (wchar_t**) malloc (sizeof(wchar_t*));
  15. positive_cats.__ptrStrings[0] = (wchar_t*) category;
  16. E_BNS_ERROR_CODE res = bns__submit_feedback(connection, kbName, &nvps, &positive_cats, language);
  17. if (res != _BNS_OK) {
  18. // Handle errors
  19. }
  20. // deallocate memory
  21. free (nvps.__ptrNVPs);
  22. free (positive_cats.__ptrStrings);
  23. // release connection
  24. bns__release_connection(pool, connection);

The purpose of each section of the preceding code is shown in the following list, by line numbers:

1-2
Acquires a connection to the system from the connection pool (it is assumed that the pool variable has been initialized)
3-8
Creates and populates the field definition (name-value pair) array
9-10
Sets the language to an empty string. The language will be set by the system.
11-15
Creates and populates the positive categories array
16
The actual call to SubmitFeedback
17-19
Error handling
20-22
Releases the field definition and positive categories array
23-24
Releases the connection to the system back to the pool. All memory associated with the connection will be released.

Sample code: Java™

  1. // Build and populate the NVP array
  2. NVP[] nvps = new NVP[1];
  3. nvps[0] = new NVP();
  4. nvps[0].setName(nvpName);
  5. nvps[0].setValue(text);
  6. // Set the language to null
  7. String lang = null;
  8. // Build and populate the positive feedback array
  9. String positive[] = new String[1];
  10. positive[0] = category;
  11. try {
  12. // Submit the feedback
  13. m_servicePortType.submitFeedback(kbName, nvps, positive, lang);
  14. } catch (java.rmi.RemoteException e) {
  15. // Handle errors
  16. }

The purpose of each section of the preceding code is shown in the following list, by line numbers:

1-5
Creates and populates the field definition (name-value pair) array
6-7
Sets the language to an empty string. The language will be set by the system.
8-10
Creates and populates the positive categories array
12-13
The actual call to SubmitFeedback
14-16
Error handling

Sample code: Visual Basic

  1. Dim objBNSConnection As BNSCOMCLIENTLib.BnsConnection
  2. Dim objBNSFeedback As New BNSCOMCLIENTLib.BnsStringCollection
  3. Dim objBNSQuestion As New BNSCOMCLIENTLib.BnsNvpCollection
  4. Dim sKBName As String
  5. Dim sNVPName As String
  6. Dim sText As String
  7. Dim sCategoryName As String
  8. Dim sLanguageName As String
  9. sKBName = "20 Newsgroups"
  10. sNVPName = "Questions"
  11. sText = "my text for feedback"
  12. sCategoryName = "misc.forsale"
  13. sLanguageName = ""
  14. objBNSQuestion.Add sNVPName, sText
  15. objBNSFeedback.Add sCategoryName
  16. Set objBNSConnection = m_objBnsConnectionPool.AcquireConnection
  17. objBNSConnection.SubmitFeedback sKBName, objBNSQuestion, objBNSFeedback, sLanguageNameDim objBNSConnection As BNSCOMCLIENTLib.BnsConnection

The purpose of each section of the preceding code is shown in the following list, by line numbers:

1-8
Variable definition and allocation
10-14
Variable initialization: knowledge base name, field name, text, category for feedback, language
16
Adds the field definition to the collection of fields
17
Adds the category to the list of categories for feedback
29
Acquires a connection from the pool
21
The actual call to SubmitFeedback

Sample code: .NET

  1. BanterServerSvc.BanterServerWebService srv;
  2. string sURL;
  3. string sKBName;
  4. string sNVPName;
  5. string sText;
  6. string sLanguage;
  7. string sTextCategoryName;
  8. sURL = "http://localhost:18087";
  9. sKBName = "20 Newsgroups";
  10. sNVPName = "Question";
  11. sText = "My question text for suggest";
  12. sLanguage = "";
  13. sTextCategoryName = "misc.forsale";
  14. srv = new BanterServerSvc.BanterServerWebService();
  15. srv.Url = sURL;
  16. BanterServerSvc.NVP[] nvps = new BanterServerSvc.NVP[1];
  17. nvps[0] = new BanterServerSvc.NVP();
  18. nvps[0].Name = sNVPName;
  19. nvps[0].Value = sText;
  20. string[] positive = new string[1];
  21. positive[0] = sTextCategoryName;
  22. srv.SubmitFeedback (sKBName, nvps, positive, sLanguage);

The purpose of each section of the preceding code is shown in the following list, by line numbers:

1-7
Variable definition and allocation
10-14
Variable initialization: Server URL, knowledge base name, field name, text, language, category for feedback
16-17
Allocation of BanterServerWebService instance, and definition of the Server URL
19-22
Allocation of the field definition (name-value pair) array and adding the field to the field definition array
24-25
Adds the category to the list of categories for feedback
26
The actual call to SubmitFeedback