예제 #1
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            var text         = this.inputBox.Text;
            var client       = new EntityLinkingServiceClient("6a15dbc029324c9caefcaece90863e28");
            var linkResponse = await client.LinkAsync(text);

            var result = string.Join(", ", linkResponse.Select(i => i.WikipediaID).ToList());

            this.outputBlock.Text = result;
        }
        private async void OnButtonClickedAsync(object sender, EventArgs e)
        {
            var text = txtvalue.Text;
            EntityLinkingServiceClient client = new EntityLinkingServiceClient("e52917bb34d1426f80ac816dc818e8de", "https://api.labs.cognitive.microsoft.com");


            var linkResponse = await client.LinkAsync(text);

            var result = string.Join(", ", linkResponse.Select(i => i.WikipediaID).ToList());

            this.outputBlock.Text = result;
            //await MakeRequest();
        }
예제 #3
0
        // Get Entitiy Linking results for input text
        private async void btnGetResult_Click(object sender, RoutedEventArgs e)
        {
            var text = this.inputBox.Text;

            // Create a new Cognitive Services Entity Linking Service client, pass our subscription ID
            var client = new EntityLinkingServiceClient("b2663927e9d242269740dd5390070e76");
            // Send our text for entity linking
            var linkResponse = await client.LinkAsync(text);

            // Display the results
            var result = string.Join(", ", linkResponse.Select(i => i.WikipediaID).ToList());

            this.outputBlock.Text = result;
        }
예제 #4
0
        /// <summary>
        /// Function to link entities
        /// </summary>
        /// <param name="inputText">Input text to link entities from</param>
        /// <param name="selection">Given entity to link from, defaults to empty string</param>
        /// <param name="offset">If an entity has been given, this offset specifies the first place its found in the text. Defaults to 0</param>
        /// <returns>Array containing <see cref="EntityLink"/> objects</returns>
        public async Task <EntityLink[]> LinkEntities(string inputText, string selection = "", int offset = 0)
        {
            try
            {
                EntityLink[] linkingResponse = await _entityLinkingServiceClient.LinkAsync(inputText, selection, offset);

                return(linkingResponse);
            }
            catch (Exception ex)
            {
                RaiseOnEntityLinkingError(new EntityLinkingErrorEventArgs(ex.Message));
                return(null);
            }
        }
예제 #5
0
        public static async Task <List <EntityLink> > LinkEntityAsync(string text)
        {
            var linkResponse = await _visionServiceClient.LinkAsync(text);

            var result = new List <EntityLink> ();

            foreach (var link in linkResponse)
            {
                result.Add(new EntityLink()
                {
                    Name        = link.Name,
                    Score       = link.Score,
                    WikipediaID = link.WikipediaID
                });
            }
            return(result);
        }
예제 #6
0
        private static Task <EntityLink[]> GetLinkedEntitiesAsync(params string[] txts)
        {
            var txt = string.Join(Environment.NewLine, txts);

            if (string.IsNullOrWhiteSpace(txt))
            {
                return(Task.FromResult <EntityLink[]>(null));
            }

            // truncate each page to 10k charactors
            if (txt.Length > 10000)
            {
                txt = txt.Substring(0, 10000);
            }

            return(linkedEntityClient.LinkAsync(txt));
        }
예제 #7
0
        public static async Task <string> getEntityLink(string messageBody)
        {
            //Set up response
            var response = "";

            try
            {
                //Step 2a: Call into the Entity Linking API;
                EntityLink[] entityResult;
                var          ELISClient = new EntityLinkingServiceClient(Keys.ELIS);
                entityResult = await ELISClient.LinkAsync(messageBody);

                //Step 2b: Store the results as a comma separated list of wikipedia URLs
                response += string.Join(", ", entityResult.Select(i => "https://en.wikipedia.org/wiki/" + i.WikipediaID.Replace(" ", "_")).ToList());
            }
            catch (Exception ex)
            {
                response = ex.ToString();
            }

            //Return response
            return(response);
        }