예제 #1
0
        public void Success_Cace()
        {
            if (string.IsNullOrEmpty(CotohaApiManager.BearerValue))
            {
                CotohaApiManager.GetAccessTokenAsync().Wait();
            }


            var result = CotohaApiManager.ExtractionKeywordsAsync(new KeyWordRequest()
            {
                Document = new List <string>()
                {
                    "レストランで昼食を食べた。"
                },
                Type          = "kuzure",
                DoSegment     = true,
                MaxKeywordNum = 2
            }).Result;

            Assert.AreEqual(2, result.Result.Count);

            var resultList = result.Result.ToList();

            Assert.IsTrue(resultList.Where(i => i.Form == "レストラン").Count() > 0);
            Assert.IsTrue(resultList.Where(i => i.Form == "昼食").Count() > 0);
        }
예제 #2
0
        public void Failure_LongTextCace()
        {
            if (string.IsNullOrEmpty(CotohaApiManager.BearerValue))
            {
                CotohaApiManager.GetAccessTokenAsync().Wait();
            }


            var result = CotohaApiManager.ExtractionKeywordsAsync(new KeyWordRequest()
            {
                //282文字
                Document = new List <string>()
                {
                    "階層的な行セット、つまりチャプター (OLE DB 型DBTYPE_HCHAPTER、ADO 型adChapter) を使用して取得できます、OleDbDataReaderします。 チャプターを含むクエリとして返される場合、 DataReader、章を内の列として返されますDataReaderとして公開されると、 DataReaderオブジェクト。",
                    "ADO.NETデータセットテーブル間の親子リレーションシップを使用して階層的な行セットを表すためも使用できます。詳細については、次を参照してください。",
                    "Dataset、Datatable、および Dataviewします。",
                    "MSDataShape プロバイダーを使用して、顧客リストの顧客別オーダーのチャプター列を生成するコード サンプルを次に示します。",
                    "NET Framework Data Provider for Oracle は、クエリ結果を返すために、Oracle REF CURSOR の使用をサポートしています。 Oracle REF CURSOR は OracleDataReader として返されます。"
                },
                Type          = "kuzure",
                DoSegment     = true,
                MaxKeywordNum = 10
            }).Result;

            Assert.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode);
        }
예제 #3
0
        public void Success_Pattern02Cace()
        {
            var task   = CotohaApiManager.GetAccessTokenAsync();
            var result = task.Result;

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);
            Assert.IsFalse(string.IsNullOrWhiteSpace(CotohaApiManager.BearerValue));
        }
예제 #4
0
        public void Failure_BearerEmptyCase()
        {
            var result = CotohaApiManager.SentimentAnalysisAsync(new SentimentRequest()
            {
                Sentence = "人生の春を謳歌しています"
            }).Result;

            Assert.AreEqual(result.StatusCode, HttpStatusCode.NotAcceptable);
        }
예제 #5
0
        public void Success_Cace()
        {
            CotohaApiManager.GetAccessTokenAsync().Wait();
            System.Diagnostics.Debugger.Break();

            var result = CotohaApiManager.SentimentAnalysisAsync(new SentimentRequest()
            {
                Sentence = "人生の春を謳歌しています"
            }).Result;

            //TODO TEST 単体実行では成功するが、VSから一括実行すると、成功しない(NullReferrenceの例外)
            Assert.AreEqual("Positive", result.Result.Sentiment);
        }
예제 #6
0
        public void Success_Pattern01Cace()
        {
            var task = CotohaApiManager.GetAccessTokenAsync(new AccessTokenRequest()
            {
                GrantType    = "client_credentials",
                ClientId     = CotohaAPI.Settings.AccountInfo.DeveloperClientId,
                ClientSecret = CotohaAPI.Settings.AccountInfo.DeveloperClientSecret
            });

            var result = task.Result;

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);
            Assert.IsFalse(string.IsNullOrWhiteSpace(CotohaApiManager.BearerValue));
        }
예제 #7
0
        public void Failure_BearerEmptyCase()
        {
            CotohaApiManager.BearerValue = string.Empty;
            var result = CotohaApiManager.ExtractionKeywordsAsync(new KeyWordRequest()
            {
                Document = new List <string>()
                {
                    "レストランで昼食を食べた。"
                },
                Type          = "kuzure",
                DoSegment     = true,
                MaxKeywordNum = 2
            }).Result;

            Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private async Task ExecuteAnalysis(AnalysisModel model)
        {
            var tokenResult = await CotohaApiManager.GetAccessTokenAsync();

            if (tokenResult.StatusCode == HttpStatusCode.Created)
            {
                model.KeywordResult = await CotohaApiManager.ExtractionKeywordsAsync(new CotohaAPI.Models.KeyWordRequest()
                {
                    Document      = model.Presenter.SpeachText,
                    Type          = "kuzure",
                    DoSegment     = true,
                    MaxKeywordNum = 10
                });

                model.KeyPhraseExtractResult =
                    await TextAnalyticsManager.ExecuteJapaneseKeyPhraseExtractAsync(string.Join("。", model.Presenter.SpeachText));
            }
        }