Introduction
In this article, I am going to explain how to use Azure Text Analytics API in a simple WPF application. Azure Cognitive Services provides the Text Analytics API. It is an advanced cloud-based service that is used for natural language processing. The main functions of Text Analytics API are sentiment analysis, key phrase extraction, named entity recognition, and language detection.
Language Detection
The Language Detection API returns the detected language. It evaluates the input from the user and returns the language with a score.
The score completely depends on the strength of the analysis.
How can I use this API in my WPF Application?
You can use the Text Analytics API in any of your applications. For example, I am using it with a WPF application. In this article, I will not explain anything in detail about the WPF application. So, just refer to the WPF application and its uses before using Text Analytics API.
Let's get started
Follow the simple steps given below.
Open Visual Studio. Create a new WPF app (.NET Core) project.

Drag and drop the controls as given below in the screenshot.

Right-click the solution and select "Manage NuGet Packages for Solution". Download Newtonsoft.json from the list.

Create a new resource in the Azure portal. Search for Text Analytics in the search pane. Once done, extract the keys and copy paste them on the Notepad.

Follow the code given below for designing the mainwindow.xaml.
- <Grid Margin="-226,-26,-299,-82">
- <StackPanel HorizontalAlignment="Left" Height="413" Margin="261,50,0,0" VerticalAlignment="Top" Width="736" RenderTransformOrigin="0.5,0.5">
- <StackPanel.RenderTransform>
- <TransformGroup>
- <ScaleTransform ScaleX="-1"/>
- <SkewTransform/>
- <RotateTransform/>
- <TranslateTransform/>
- </TransformGroup>
- </StackPanel.RenderTransform>
- <Label Content="Write Message Here" Height="108" FontSize="48" FontFamily="Segoe UI Black" Margin="236,0,130,0" RenderTransformOrigin="0.5,0.5">
- <Label.RenderTransform>
- <TransformGroup>
- <ScaleTransform ScaleX="-1"/>
- <SkewTransform/>
- <RotateTransform/>
- <TranslateTransform/>
- </TransformGroup>
- </Label.RenderTransform>
- </Label>
- <TextBox Height="49" x:Name="txtbox" TextWrapping="Wrap" Text="" Margin="13,0,8,0" RenderTransformOrigin="0.5,0.5">
- <TextBox.RenderTransform>
- <TransformGroup>
- <ScaleTransform ScaleX="-1"/>
- <SkewTransform/>
- <RotateTransform/>
- <TranslateTransform/>
- </TransformGroup>
- </TextBox.RenderTransform>
- </TextBox>
- <Button Content="Translate" Height="84" RenderTransformOrigin="0.5,0.5" Margin="173,0,159,0" FontSize="48" FontWeight="Bold" Click="Button_Click">
- <Button.RenderTransform>
- <TransformGroup>
- <ScaleTransform ScaleX="-1"/>
- <SkewTransform/>
- <RotateTransform/>
- <TranslateTransform/>
- </TransformGroup>
- </Button.RenderTransform>
- </Button>
- <Label Content="" x:Name="label1" Height="87" FontSize="36" Margin="13,0,17,0" RenderTransformOrigin="0.5,0.5">
- <Label.RenderTransform>
- <TransformGroup>
- <ScaleTransform ScaleX="-1"/>
- <SkewTransform/>
- <RotateTransform/>
- <TranslateTransform/>
- </TransformGroup>
- </Label.RenderTransform>
- </Label>
- </StackPanel>
- </Grid>



Menaka Priyadharshini BPosted May 31, 2019, 10:27 AM
Thank you Barnabas
Barnabas OlutayoPosted May 31, 2019, 10:18 AM
Wow this is a nice article. I love it, I will try it out.