public async static Task <BosonNLP.Contract.DependencyGrammarModel> DependencyGrammar(string input) { if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { TipServices.TipNoInternet(); return(null); } if (input == "") { return(null); } try { return(await BosonNLP.Single.DependencyGrammar.DependencyGrammarAnalysis(input)); } catch { TipServices.TipSystemError(); return(null); } }
public async static Task <string> SummaryAnalysis(string input) { if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { TipServices.TipNoInternet(); return(null); } if (input == "") { return(null); } try { return(await BosonNLP.Single.Summary.SummaryAnalysis(input)); } catch { TipServices.TipSystemError(); return(null); } }
public async static Task <BosonNLP.Contract.NamedEntityModel> NamedEntityRecognize(string input) { if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { TipServices.TipNoInternet(); return(null); } if (input == "") { return(null); } try { return(await BosonNLP.Single.NamedEntity.NamedEntityRecognize(input)); } catch { TipServices.TipSystemError(); return(null); } }
public async static Task <BosonNLP.Contract.SegTagModel> WordSegAndTag(string input) { if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { TipServices.TipNoInternet(); return(null); } if (input == "") { return(null); } try { return(await BosonNLP.Single.SegTag.WordSegAndTag(input)); } catch { TipServices.TipSystemError(); return(null); } }
public async static Task <TencentAI.Contract.NaturalLanguage.WordSynonymModel> WordSynonym(string input) { if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { TipServices.TipNoInternet(); return(null); } if (input == "") { return(null); } try { return(await TencentAI.NaturalLanguage.BaseTextAnalyze.WordSynonymAnalyzing(input)); } catch { TipServices.TipSystemError(); return(null); } }
public async static Task <TencentAI.Contract.NaturalLanguage.WordComponentModel> WordComponent(string input) { if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { TipServices.TipNoInternet(); return(null); } if (input == "") { return(null); } try { return(await TencentAI.NaturalLanguage.SemanticAnalyze.IntentionComponentIdentification(input)); } catch { TipServices.TipSystemError(); return(null); } }
private async void OnBosonAIGo(object sender, RoutedEventArgs e) { animationView.Visibility = Visibility.Visible; ResetAll(); try { await OnSegTag(); await OnNamedEntityRecognize(); await OnEmotionAnalysis(); await OnClassify(); await OnSummary(); await OnKeywords(); await OnGetSuggest(); } catch { TipServices.TipRecognizeFailed(); } animationView.Visibility = Visibility.Collapsed; TipServices.TipRecognizeSucceed(); }
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(); } } }