private void ResetAll() { SegTagItems.Clear(); NamedEntityItems.Clear(); chartItems.Clear(); sliderClassify.Value = sliderTencentClassify.Value = 0; textSummary.Text = ""; KeywordsItems.Clear(); SuggestItems.Clear(); }
private async Task GetTencentAIResponse() { try { resTencentPosTag = await TencentAIHelper.WordPositionTagging(textInput.Text.Trim()); if (resTencentPosTag != null && resTencentPosTag.ret == 0 && resTencentPosTag.msg == "ok") { SegTagItems.Clear(); listBaseTokens = resTencentPosTag.data.base_tokens; listMixTokens = resTencentPosTag.data.mix_tokens; } resTencentProperNouns = await TencentAIHelper.WordProperNouns(textInput.Text.Trim()); if (resTencentProperNouns != null && resTencentProperNouns.ret == 0 && resTencentProperNouns.msg == "ok") { NamedEntityItems.Clear(); foreach (var item in resTencentProperNouns.data.ner_tokens) { NLPWord nlp = new NLPWord { word = item.word, width = item.length * 20, bgcolor = NameEntityHelper.GetNameEntityColor_Tencent(item.types[0].ToString()) }; NamedEntityItems.Add(nlp); } } resTencentSynonym = await TencentAIHelper.WordSynonym(textInput.Text.Trim()); if (resTencentSynonym != null && resTencentSynonym.ret == 0 && resTencentSynonym.msg == "ok") { SuggestItems.Clear(); foreach (var item in resTencentSynonym.data.syn_tokens) { NLPWord nlp = new NLPWord { word = item.ori_word.word, width = item.ori_word.length * 20, bgcolor = "#9acd32" }; SuggestItems.Add(nlp); foreach (var iitem in item.syn_words) { string strWeight = (Convert.ToInt32(iitem.weight * 100)).ToString(); NLPWord inlp = new NLPWord { word = iitem.word + "(" + strWeight + ")", //width = item.ori_word.length * 20, bgcolor = "#99CC67" }; SuggestItems.Add(inlp); } } } resTencentComponent = await TencentAIHelper.WordComponent(textInput.Text.Trim()); if (resTencentComponent != null && resTencentComponent.ret == 0 && resTencentComponent.msg == "ok") { sliderTencentClassify.Value = resTencentComponent.data.intent + 0.5; } else if (resTencentComponent != null && resTencentComponent.ret == 16393) { sliderTencentClassify.Value = 0.5; } resTencentEmotionPolar = await TencentAIHelper.WordEmotionPolar(textInput.Text.Trim()); if (resTencentEmotionPolar != null && resTencentEmotionPolar.ret == 0 && resTencentEmotionPolar.msg == "ok") { double positive = 0.0, negtive = 0.0; if (resTencentEmotionPolar.data.polar == 1) { positive = 1; negtive = 0; } else if (resTencentEmotionPolar.data.polar == -1) { positive = 0; negtive = 1; } else if (resTencentEmotionPolar.data.polar == 0) { positive = 1; negtive = 1; } 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 = positive, Title = "正面" }; var sliceTwo = new ChartDataModel { Value = 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 = positive, Title = "Positive" }; var sliceTwo = new ChartDataModel { Value = negtive, Title = "Negtive" }; // Add those items to the list chartItems.Add(sliceOne); chartItems.Add(sliceTwo); } MyDoughnutSeries.ItemsSource = chartItems; } TipServices.TipRecognizeSucceed(); } catch { if (resTencentPosTag.ret < 0) { TipServices.TipSystemError(); } else { TipServices.TipRecognizeFailed(); } } }