Ejemplo n.º 1
0
        private static async Task <List <List <Morph.MorphResultSet> > > MorphAnalysisAsync(string docomoApiKey)
        {
            var text   = "あらゆる現実を全て自分の方へねじ曲げたのだ";
            var client = new Morph(docomoApiKey);

            Morph.InfoFilter info = Morph.InfoFilter.FORM | Morph.InfoFilter.POS;
            var results           = await client.ExecAsync(text, info);

            return(results);
        }
Ejemplo n.º 2
0
        private async void MorphExtract(object sender, RoutedEventArgs e)
        {
            try
            {
                MorphExtractButton.IsEnabled = true;
                MorphResult.Text             = "解析中";
                var c = new Morph(APIKey);
                Morph.InfoFilter info = 0;
                if (MorphForm.IsChecked == true)
                {
                    info |= Morph.InfoFilter.FORM;
                }
                if (MorphPos.IsChecked == true)
                {
                    info |= Morph.InfoFilter.POS;
                }
                if (MorphRead.IsChecked == true)
                {
                    info |= Morph.InfoFilter.READ;
                }

                string[] list = null;
                if (!string.IsNullOrWhiteSpace(MorphPosFilter.Text))
                {
                    list = MorphPosFilter.Text.Split(',');
                }

                var text   = MorphSentence.Text;
                var result = await Task.Run(
                    async() => await c.ExecAsync(text, info, list)
                    );

                MorphResult.Text = JsonConvert.SerializeObject(result);
            }
            catch (Exception ex)
            {
                MorphResult.Text = "エラー:" + ex.Message;
            }
            finally
            {
                MorphExtractButton.IsEnabled = true;
            }
        }