private async void OnBosonAINamedEntityRecognize(object sender, RoutedEventArgs e) { animationView.Visibility = Visibility.Visible; try { resBoson = await BosonAIHelper.NamedEntityRecognize(textInput.Text.Trim()); if (resBoson.entity.Count > 0) { SampleItems.Clear(); for (int i = 0; i <= resBoson.entity.Count - 1; i++) { int nStart = Convert.ToInt32(resBoson.entity[i][0]); int nEnd = Convert.ToInt32(resBoson.entity[i][1]); List <string> list = resBoson.word.Skip(nStart).Take(nEnd - nStart).ToList(); string strEntity = ""; foreach (var item in list) { strEntity += item; } NLPWord nlp = new NLPWord { word = strEntity, width = strEntity.Length * 20, bgcolor = NameEntityHelper.GetNameEntityColor_Boson(resBoson.entity[i][2]) }; SampleItems.Add(nlp); } } } catch { } animationView.Visibility = Visibility.Collapsed; }
private async Task OnNamedEntityRecognize() { try { resBosonNamedEntity = await BosonAIHelper.NamedEntityRecognize(textInput.Text.Trim()); if (resBosonNamedEntity.entity.Count > 0) { for (int i = 0; i <= resBosonNamedEntity.entity.Count - 1; i++) { int nStart = Convert.ToInt32(resBosonNamedEntity.entity[i][0]); int nEnd = Convert.ToInt32(resBosonNamedEntity.entity[i][1]); List <string> list = resBosonNamedEntity.word.Skip(nStart).Take(nEnd - nStart).ToList(); string strEntity = ""; foreach (var item in list) { strEntity += item; } NLPWord nlp = new NLPWord { word = strEntity, width = strEntity.Length * 20, bgcolor = NameEntityHelper.GetNameEntityColor_Boson(resBosonNamedEntity.entity[i][2]) }; NamedEntityItems.Add(nlp); } } } catch { } }
private void OnClearContent(object sender, RoutedEventArgs e) { textInput.Text = ""; SampleItems.Clear(); resBoson = null; }