public async Task <IActionResult> DetectLanguage([FromBody] string fileName) { // путь к папке Files var file = System.IO.Path.Combine(_appEnvironment.WebRootPath, "Files", fileName); if (!System.IO.File.Exists(file)) { // Create a file to write to. //string createText = "File not found"; return(NotFound()); } string text = System.IO.File.ReadAllText(file); if (text == null) { // Create a file to write to. //string createText = "File not found"; return(NotFound()); } var algoritm = new DetectLanguage <AnswerModel <string> >(); Analytic <AnswerModel <string> > _analytic = new Analytic <AnswerModel <string> >(); var result = _analytic.Execute(algoritm, text); return(Ok(result)); }
public IActionResult Detect_Text([FromBody] DetectLanguage detectLanguage) { Yandex yandex = new Yandex(); var result = yandex.Detect(detectLanguage.text); return(new JsonResult(result)); }
public static async Task <LanguageManager> GetLanguage(IDialogContext context, IAwaitable <IMessageActivity> activity) { string lang; if (!context.UserData.TryGetValue <string>(QUERY_LANGUAGE, out lang)) { if (activity == null) { return(new LanguageManager(DEFAULT_LANG)); } IMessageActivity iMessage = await activity; lang = await DetectLanguage.Execute(iMessage.Text); context.UserData.SetValue <string>(QUERY_LANGUAGE, lang); } return(new LanguageManager(lang)); }