예제 #1
0
 public async Task <IActionResult> DetectLanguages(IEnumerable <string> words)
 {
     if (words.Count() != 0)
     {
         var user       = userRepository.Get(name: User.Identity.Name);
         var detector   = new Detector();
         var detections = detector.GetDetectedWords(await detector.DetectLanguages(words));
         var query      = queryRepository.Insert(user.Id);
         foreach (var el in detections)
         {
             var languageInfo = el.languages.Where(x => x.confidence != 0).FirstOrDefault() ?? new LanguagesInfo();
             detectedWordsRepository.Insert(user.Id, query.Id, el.text, languageInfo.language, languageInfo.confidence);
         }
         return(Json(detections));
     }
     else
     {
         return(Json(new { status = "failed" }));
     }
 }
예제 #2
0
 public void Create(Query query)
 {
     _queryRepository.Insert(query);
 }