// Decides how to search in websites based on query private async void InputQueryToWebsites() { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (query == "" || query == null) { // Gets query for other uses. query = NewMessageTextBox.Text; } // Strip query of punctuation & make lowercase query = CleanInput(query); // Get subject of query (topic of your knowledge base) if (set1.Contains(query)) { if (query == kbName1) { subject = " "; // don't add a subject if query is already subject word } else { subject = kbName1; } } else if (set2.Contains(query)) { if (query == kbName2) { subject = ""; // don't add a subject if query is already subject word } else { subject = kbName2; } } else if (set3.Contains(query)) { if (query == kbName3) { subject = ""; // don't add a subject if query is already subject word } else { subject = kbName3; } } else // if no subject, then must be a LUIS default intent (Greeting, Cancel, Help, or None) { subject = ""; query = ""; // Sites need the root URLs to render, rather than empty query/subject in URL Encyclopedia.Navigate(new Uri("https://en.wikipedia.org/")); MicrosoftAcademic.Navigate(new Uri("https://academic.microsoft.com/")); NewsBlogs.Navigate(new Uri("https://www.bing.com/")); return; } // Set query into Encyclopedia, Microsoft Academics, and Bing Search Encyclopedia.Navigate(new Uri("https://en.wikipedia.org/w/index.php?search=" + query + "+" + subject + "&title=Special%3ASearch&go=Go")); NewsBlogs.Navigate(new Uri("https://www.bing.com/search?q=" + query + "+" + subject)); MicrosoftAcademic.Navigate(new Uri("https://academic.microsoft.com/#/search?iq=%40" + query + "%20" + subject + "%40&q=" + query + "%20" + subject)); }); // Clears text for next query. await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { NewMessageTextBox.Text = String.Empty; }); query = ""; }
// Decides how to search in websites based on query private void inputQueryToWebsites() { // Gets query for other uses. query = NewMessageTextBox.Text; // Strip query of punctuation query = CleanInput(query); // Get subject of query (topic of your knowledge base) if (set1.Contains(query)) { if (query == kbName1) { subject = " "; // don't add a subject if query is already subject word } else { subject = kbName1; } } else if (set2.Contains(query)) { if (query == kbName2) { subject = " "; // don't add a subject if query is already subject word } else { subject = kbName2; } } else if (set3.Contains(query)) { if (query == kbName3) { subject = " "; // don't add a subject if query is already subject word } else { subject = kbName3; } } else // if no subject, then must be a LUIS default intent (Greeting, Cancel, Help, or None) { subject = ""; query = ""; // Microsoft academic needs the root URL to render, rather than empty query/subject in URL MicrosoftAcademic.Navigate(new Uri("https://academic.microsoft.com/")); } // Set query into Encyclopedia, Microsoft Academics, and Bing Search Encyclopedia.Navigate(new Uri("https://en.wikipedia.org/wiki/" + query)); NewsBlogs.Navigate(new Uri("https://www.bing.com/search?q=" + query + "%20" + subject + "&qs=n&form=QBRE&sp=-1&pq=" + query + "%20" + subject + "&sc=8-5&sk=&cvid=92D86BDF64C049B3AD2DC5444AB33E25")); if (subject != "" && query != "") { MicrosoftAcademic.Navigate(new Uri("https://academic.microsoft.com/#/search?iq=@" + query + "@&q=" + query + "&filters=&from=0&sort=0")); } // Clears text for next query. NewMessageTextBox.Text = String.Empty; }