private static async Task <double> SimirarityCalcAsync(string docomoApiKey) { var text1 = "今日は車で公園に行きました"; var text2 = "今日は電車で公園に行きました"; var client = new Similarity(docomoApiKey); var result = await client.ExecAsync(text1, text2); return(result); }
private async void SimirarityCalc(object sender, RoutedEventArgs e) { try { SimirarityCalcButton.IsEnabled = true; SimirarityResult.Text = "変換中"; var c = new Similarity(APIKey); var text1 = SimiraritySentence1.Text; var text2 = SimiraritySentence2.Text; var result = await Task.Run( async() => await c.ExecAsync(text1, text2) ); SimirarityResult.Text = result.ToString(); } catch (Exception ex) { SimirarityResult.Text = "エラー:" + ex.Message; } finally { SimirarityCalcButton.IsEnabled = true; } }