Xamarin + Azure: Part 4 – Intelligent Apps
Scope
The article shown below follows my presentation and demo at Xamarin Dev Days in Mauritius. The article demonstrates how to get started with Azure mobile apps and the benefits of the powers of Cloud in terms of scalability, Offline Sync, and Data Analytics.
Introduction
Microsoft Cognitive Services lets you build apps with powerful algorithms, using just a few lines of code. They work across the devices and platforms such as iOS, Android and Windows, keep improving, and are easy to set up.
To reach this goal, the Text Analytics API of Microsoft Cognitive Services shall be used.
Text Analytics API
Text Analytics API is a suite of text analytics Services built with Azure Machine Learning. It currently offers APIs for sentiment analysis, key phrase extraction, and topic detection for English text, as well as language detection for 120 languages.
Implementation
The objective is to automatically calculate the sentiment score when the user is submitting the feedback.
The easiest way to implement this is to modify the Cloud back-end code to add logic that will call the Text Analytics API and update the value of the field Sentiment Score as the user will submit a feedback in the Post Feedback action of the FeedbackController.
Below are the steps to proceed with this change.
1. Open the back-end project and add a new class called Analytics.2. Add variables to keep the Base URL and the Account Key.
3. Add the functions to call the Cognitive Services and get the sentiment of a text.
4. In the Feedback Controller, amend the method Post Feedback, as shown below.
This will take the Feedback text, call Cognitive Services, calculate the Sentiment Score and save it in the database.
5 In the client Application, open the page feedbackpage.xaml and add the code, mentioned below to display the sentiment score.
Demo
Open the Application and add new feedback.
Conclusion
In this article, we demonstrated how to add Text Analytics in the sample Application, using Microsoft Cognitive Services.
The takeaway here is to see how fast and easy it is to connect your Application to a Cloud back-end, benefit from a managed SQL Server, and connect to Machine Learning APIs.
References
- https://www.microsoft.com/cognitive-services/en-us/text-analytics/documentation
- https://docs.microsoft.com/en-us/azure/machine-learning/machine-learning-apps-text-analytics
- https://www.microsoft.com/cognitive-services