Before reading this article, please go through the following articles.
- Introduction To Universal Windows Platform (UWP) App Development Using Windows 10 And Visual Studio 2015
- How To Create Microsoft Cognitive Service Academic Knowledge API On Azure Portal
Microsoft Cognitive Services
Microsoft Cognitive Services (formerly Project Oxford) are a set of APIs, SDKs, and Services available to developers to make their applications more intelligent, engaging, and discoverable. Microsoft Cognitive Services expands on Microsoft’s evolving portfolio of machine learning APIs and enables developers to easily add intelligent features. Microsoft Cognitive Services let you build apps with powerful algorithms using just a few lines of code. They work across devices and platforms such as iOS, Android, and Windows, keep improving, and are easy to set up.
Academic Knowledge API
With an Academic Knowledge API, we will be able to interpret the user queries for the academic intent and retrieve the rich information from Microsoft Academic Graph (MAG). MAG knowledge-base is a Web-scale heterogeneous entity graph, made of entities that model scholarly activities: field of study, author, institution, paper, venue and event.
Academic Knowledge API consists of three related REST endpoints.
- Interpret
The interpret REST API takes an end user query string (i.e., a query entered by a user of your application) and returns formatted interpretations of user intent based n the Academic Graph data and the Academic Grammar. - Evaluate
It evaluates a query expression and returns Academic Knowledge entity results. - Calchistogram
It calculates a histogram of the distribution of the attribute values for the academic entities returned by a query expression, such as the distribution of citations by year for a given author.
The following important tools are required for developing UWP.
- Windows 10 (Recommended).
- Visual Studio 2015 Community Edition (It is a free software available online).
- Cognitive Service Academic Knowledge API Key (using Azure How To Create Microsoft Cognitive Service Academic Knowledge API On Azure Portal).
Now, we can discuss step by step app development.
Step 1
Open Visual studio 2015 -> Start -> New Project -> Select Universal (under Visual C# -> Windows) -> Blank App -> Give suitable name to your app (UWPCogAcadInterpret) -> OK.

After choosing the target and minimum platform version that your Windows Universal Application will support, the Project creates App.xaml and MainPage.xaml.

Step 2
Add AutoSuggestBox control, set the name and text properties for Search.

Add a Button control, set the name and add the search icon for Find video.

Step 3
Add GridView Resources, using the code, mentioned below.
- <Grid.Resources>
- <CollectionViewSource x:Name="SearchResultsCol" Source="{x:Bind SearchResults}" IsSourceGrouped="False" />
- </Grid.Resources>
- <GridView x:Name="gvCogAcKnIn" ItemsSource="{Binding Source={StaticResource SearchResultsCol}}" SelectionMode="None" IsItemClickEnabled="False" HorizontalAlignment="Left" Height="433" Margin="71,233,0,0" VerticalAlignment="Top" Width="1117" Background="#FFF7FFFF">

Add the following code for Grid View Item Template for Journal details.
- <GridView.ItemTemplate>
- <DataTemplate>
- <Border Background="#FF07FDF2" Width="1098" Height="123" Margin="8">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="auto" />
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <Grid Grid.Column="1" Margin="3,3,3,10">
- <Grid.RowDefinitions>
- <RowDefinition Height="auto" />
- </Grid.RowDefinitions>
- <StackPanel Margin="0,0,0,-143">
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.Title}" Style="{StaticResource CaptionTextBlockStyle}" FontWeight="Bold" />
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.Year}" Style="{StaticResource CaptionTextBlockStyle}" />
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.Citationcount}" Style="{StaticResource CaptionTextBlockStyle}" />
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.Authorname}" Style="{StaticResource CaptionTextBlockStyle}" />
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.AuthorID}" Style="{StaticResource CaptionTextBlockStyle}" />
- </StackPanel>
- </Grid>
- </Grid>
- </Border>
- </DataTemplate>
- </GridView.ItemTemplate>
Add the Click event method for Search button.

Step 5
Open (double click) the file MainPage.xaml in the Solution Explorer and add the Newtonsoft.Json reference in the project. Right click your project (UWPCogAcadInterpret) and select "Manage NuGet Packages".

For adding Newtonsoft.Json Reference, choose Browse and Search Newtonsoft.Json. Select the package and install it.

Reference is added to your project.

Note
Automatically, the following code will be generated in XAML code view, while we are done in the design view.
- <Page x:Class="UWPCogAcadInterpret.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:UWPCogAcadInterpret" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <Grid.Resources>
- <CollectionViewSource x:Name="SearchResultsCol" Source="{x:Bind SearchResults}" IsSourceGrouped="False" />
- </Grid.Resources>
- <TextBlock x:Name="tblTitle" HorizontalAlignment="Left" Margin="296,83,0,0" TextWrapping="Wrap" Text="UWP Coginitive Service Academy Knowledge Interpret Method - Demo" VerticalAlignment="Top" FontWeight="Bold" FontSize="22" />
- <AutoSuggestBox x:Name="asbinter" HorizontalAlignment="Left" Margin="325,174,0,0" VerticalAlignment="Top" Width="523" FontSize="18" />
- <Button x:Name="btnAcKnInt" HorizontalAlignment="Left" Margin="856,174,0,0" VerticalAlignment="Top" Click="btnAcKnInt_Click">
- <SymbolIcon Symbol="Find"></SymbolIcon>
- </Button>
- <GridView x:Name="gvCogAcKnIn" ItemsSource="{Binding Source={StaticResource SearchResultsCol}}" SelectionMode="None" IsItemClickEnabled="False" HorizontalAlignment="Left" Height="433" Margin="71,233,0,0" VerticalAlignment="Top" Width="1117" Background="#FFF7FFFF">
- <GridView.ItemTemplate>
- <DataTemplate>
- <Border Background="#FF07FDF2" Width="1098" Height="123" Margin="8">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="auto" />
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <Grid Grid.Column="1" Margin="3,3,3,10">
- <Grid.RowDefinitions>
- <RowDefinition Height="auto" />
- </Grid.RowDefinitions>
- <StackPanel Margin="0,0,0,-143">
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.Title}" Style="{StaticResource CaptionTextBlockStyle}" FontWeight="Bold" />
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.Year}" Style="{StaticResource CaptionTextBlockStyle}" />
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.Citationcount}" Style="{StaticResource CaptionTextBlockStyle}" />
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.Authorname}" Style="{StaticResource CaptionTextBlockStyle}" />
- <TextBlock TextWrapping="Wrap" Text="{Binding evco.AuthorID}" Style="{StaticResource CaptionTextBlockStyle}" />
- </StackPanel>
- </Grid>
- </Grid>
- </Border>
- </DataTemplate>
- </GridView.ItemTemplate>
- </GridView>
- </Grid>
- </Page>



Munish APosted Oct 26, 2017, 12:11 PM
Nice article sir.............