public async Task <List <Entity> > GetAllEntities(bool verbose = false) { var entitiesList = new List <Entity>(); try { var command = new Command { Id = EnvelopeId.NewId(), To = Node.Parse("*****@*****.**"), Uri = new LimeUri($"/entities"), Method = CommandMethod.Get, }; _logger.LogDebug("Start get entities"); var envelopeResult = await RunCommandAsync(command); var entities = envelopeResult.Resource as DocumentCollection ?? new DocumentCollection { Items = Enumerable.Empty <Document>().ToArray() }; var counter = 0; var totalEntities = entities.Total; var str = BuildProcessBarLog(totalEntities, counter); _logger.LogTrace(str.ToString()); foreach (var entity in entities) { entitiesList.Add(entity as Entity); counter++; str = BuildProcessBarLog(totalEntities, counter); _logger.LogTrace(str.ToString()); } _logger.LogDebug("Finish get entities"); return(entitiesList); } catch (HttpRequestException e) { _logger.LogError(e, "\nException Caught!"); _logger.LogError(e, "Message :{0} ", e.Message); return(null); } }
private async Task BuildResult(DataBlock dataBlock) { lock (_locker) { _count++; if (_count % 100 == 0) { _logger.LogDebug($"{_count}/{_total}"); } } try { var input = dataBlock.Input; var analysis = dataBlock.NLPAnalysisResponse; var content = dataBlock.ContentFromProvider; if (analysis == null) { return; } var resultData = new ReportDataLine { Id = dataBlock.Id, Input = input, Intent = analysis.Intentions?[0].Id, Confidence = analysis.Intentions?[0].Score, Entities = analysis.Entities?.ToList().ToReportString(), AnalysisResponse = dataBlock.NLPAnalysisResponse }; if (content != null) { resultData.Answer = ExtractAnswer(content); } var report = new Report { ReportDataLines = new List <ReportDataLine> { resultData }, FullReportFileName = dataBlock.ReportOutputFile, WriteRawContent = dataBlock.ShouldWriteRawContent }; await _fileService.WriteAnalyseReportAsync(report, true); _logger.LogTrace($"\"{resultData.Input}\"\t{resultData.Intent}:{resultData.Confidence:P}\t{resultData.Entities}\t{CropText(resultData.Answer, 50)}"); } catch (Exception ex) { _logger.LogError(ex, $"Unexpected error BuildResult for {dataBlock}"); throw ex; } }