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 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 OnSummary() { string res = await BosonAIHelper.SummaryAnalysis(textInput.Text.Trim()); if (res != null) { textSummary.Text = res; } }
private async Task OnClassify() { resBosonClassify = await BosonAIHelper.ClassifyNews(textInput.Text.Trim()); if (resBosonClassify != null) { sliderClassify.Value = resBosonClassify.area + 0.5; } }
private async Task OnSegTag() { resBosonSegTag = await BosonAIHelper.WordSegAndTag(textInput.Text.Trim()); if (resBosonSegTag != null && resBosonSegTag.tag.Count > 0) { for (int i = 0; i <= resBosonSegTag.tag.Count - 1; i++) { NLPWord nlp = new NLPWord { word = resBosonSegTag.word[i], width = resBosonSegTag.word[i].Length * 20, bgcolor = PosTagHelper.GetPosColor_Boson(resBosonSegTag.tag[i]) }; SegTagItems.Add(nlp); } } }
private async Task OnEmotionAnalysis() { resBosonEmotion = await BosonAIHelper.EmotionAnalysis(textInput.Text.Trim()); if (resBosonEmotion != null) { if ((Application.Current as App).strCurrentLanguage.ToLower().Equals("zh-cn")) { // Create a new chart data point for each value you want in the PieSeries var sliceOne = new ChartDataModel { Value = resBosonEmotion.positive, Title = "正面" }; var sliceTwo = new ChartDataModel { Value = resBosonEmotion.negtive, Title = "负面" }; // Add those items to the list chartItems.Add(sliceOne); chartItems.Add(sliceTwo); } else { // Create a new chart data point for each value you want in the PieSeries var sliceOne = new ChartDataModel { Value = resBosonEmotion.positive, Title = "Positive" }; var sliceTwo = new ChartDataModel { Value = resBosonEmotion.negtive, Title = "Negtive" }; // Add those items to the list chartItems.Add(sliceOne); chartItems.Add(sliceTwo); } MyDoughnutSeries.ItemsSource = chartItems; } }
private async Task OnGetSuggest() { List <string> list = await BosonAIHelper.GetSuggest(textInput.Text.Trim()); if (list != null && list.Count > 0) { var brush = (SolidColorBrush)Application.Current.Resources["SystemControlHighlightListAccentLowBrush"]; for (int i = 0; i <= list.Count - 1; i++) { string[] arr = list[i].Split(','); int relative = Convert.ToInt32(Convert.ToDouble(arr[0]) * 100); NLPWord nlp = new NLPWord { word = arr[1] + " (" + relative + ")", //width = resBosonSegTag.word[i].Length * 20, bgcolor = "#99CC67"//brush.Color.ToString() }; SuggestItems.Add(nlp); } } }