Book Image

Learning Microsoft Cognitive Services - Third Edition

By : Leif Larsen
Book Image

Learning Microsoft Cognitive Services - Third Edition

By: Leif Larsen

Overview of this book

Microsoft Cognitive Services is a set of APIs for integrating artificial intelligence in your applications to solve logical business problems. If you’re new to developing applications with AI, Learning Microsoft Cognitive Services will give you a comprehensive introduction to Microsoft’s AI stack and get you up-to-speed in no time. The book introduces you to 24 APIs, including Emotion, Language, Vision, Speech, Knowledge, and Search. Using Visual Studio, you can develop applications with enhanced capabilities for image processing, speech recognition, text processing, and much more. Moving forward, you will work with datasets that enable your applications to process various data in the form of image, video, or text. By the end of the book, you’ll be able to confidently explore Cognitive Services APIs for building intelligent applications that can be deployed for real-world business uses.
Table of Contents (17 chapters)
Learning Microsoft Cognitive Services - Third Edition
Contributors
Acknowledgments
Preface
Index

Getting the news


Using the Bing News Search API, we can search for news in several ways. There are three endpoints we can use for this API:

  • /news: Get top news articles, based on category

  • /news/search: Get news articles based on a search query

  • /news/trendingtopics: Get top trending news topics

In our smart-house application, we will add the first two, while we will only cover the last one theoretically.

Note

If you have not already done so, sign up for the Bing News Search API at https://portal.azure.com.

News from queries

A lot of the groundwork for query-based news searches has already been done in the web search sample. To search for news based on given queries, we need to add a new function in the BingSearch class.

Open the BingSearch.cs file and add a new function called SearchNews. This should accept a string and a SafeSearch parameter. The function should be marked as async, and return a Task<BingNewsResponse> object:

public async Task<BingNewsResponse> SearchNews(string query...