Aida-chiyo-Talk-app

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 6a2e231b2e94f7c8118210b4753e4780a6dedce9
parent bf957f17296dce22574e0408cc682b66eb66088d
Author: Minerva-Juppiter <ryouturn@gmail.com>
Date:   Fri, 28 Jul 2023 17:18:36 +0900


Diffstat:
MInputs.cs | 39+++++++++++++++++++++++++++++++++++++++
MProgram.cs | 7+++++--
ATalkEngine.cs | 22++++++++++++++++++++++
3 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/Inputs.cs b/Inputs.cs @@ -1,6 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http.Headers; +using System.Net.Http.Json; +using System.Net; using System.Text; using System.Threading.Tasks; @@ -18,5 +21,41 @@ namespace Aida_chiyo_Talk_app } return inputString; } + public async Task<string> Proofreading(string unproofread) + { + string APIurl = "https://api.a3rt.recruit.co.jp/proofreading/v2/typo"; + string APIkey = "DZZr8Yho8FWTYiQoXDXOHOOp96S2cEsN"; + string sensitivity = "medium"; + //string APIsecret = APIurl + "?" + APIkey; + // Web API を呼ぶための HttpClient を作る + var client = new HttpClient(); + // POST メソッドで JSON の Body のリクエストを投げる + var response = await client.PostAsJsonAsync(APIurl, new RequestBody { apikey = APIkey , sentence = unproofread , sensitivity = sensitivity }); + // レスポンスのステータスコードが成功していたら Answer の値を出力 + if (response.IsSuccessStatusCode) + { + var responseBody = await response.Content.ReadFromJsonAsync<Response>(); + //Console.WriteLine(responseBody?.Answer); + return responseBody?.Answer.ToString(); + } + else + { + return string.Empty; + } + } + +// リクエストとレスポンス + class RequestBody + { + public string? apikey { get; set; } + public string? callback { get; set; } + public string? sentence { get; set; } + public string? sensitivity { get; set; } + } + + class Response + { + public string? Answer { get; set; } + } } } diff --git a/Program.cs b/Program.cs @@ -7,4 +7,7 @@ Console.WriteLine("We have woke up."); Console.WriteLine("Input someting you like."); Inputs inputs = new Inputs(); -string input = inputs.InputConsole();- \ No newline at end of file +string input = inputs.InputConsole(); + +string proofreaded = inputs.Proofreading(input).ToString(); +Console.WriteLine(proofreaded);+ \ No newline at end of file diff --git a/TalkEngine.cs b/TalkEngine.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aida_chiyo_Talk_app +{ + internal class TalkEngine + { + public string CallTalkAPI(string callTalkAPI) + { + string answer; + answer = string.Empty; + + + + + return answer; + } + } +}