- Watson Discovery: A cognitive search and content analytics engine for applications to identify patterns, trends, and actionable insights.
- Clone the repo
- Create IBM Cloud services
- Load the Discovery files
- Configure credentials
- Run the application
git clone https://github.com/modlanglais/csharp-discovery-example
Create the following services:
Launch the Watson Discovery tool. Create a new data collection by selecting the Update your own data option. Give the data collection a unique name.
When prompted to get started by uploading your data, select and upload your files. Once uploaded, you can then use the Configure data
option to add the Keyword Extraction
enrichment.
Note: failure to do this will result in no
keywords
being shown in the app.
Once the enrichments are selected, use the Apply changes to collection
button. Warning - this make take several minutes to complete.
There may be a limit to the number of files you can upload, based on your IBM Cloud account permissions.
Adding a .env file would be simpler, but for this iteration of this application the credentials will just be hard-corded. Warning Do NOT upload your application without first hiding your credentials!
Edit the Program.cs
file to add your credentials on the following lines:
// Add the environment and collection IDs here
String environmentId = "{environment-id}";
String collectionId = "{collection-id}";
TokenOptions tokenOptions = new TokenOptions()
{
// Add your URL and API key here
IamApiKey = "{api-key}",
ServiceUrl = "{url}"
};
// Add the Discovery version here
DiscoveryService service = new DiscoveryService(tokenOptions, "{version}");
// Add the query you would like to use here, i.e. "purple houses"
String inputQuery = "{your natural language query here}";
- Install .Net, etc.
- Start the app by running
dotnet run
. - This is a command line application, so there is no UI.