public async Task <string> Classify(FileInfo file) { var dataHolder = testClient.CreateTestDataset(); var parsed = await parser.ParseDocument(file.Directory, file, CancellationToken.None).ConfigureAwait(false); if (parsed == null || parsed.WordsTable.Count == 0) { return(string.Empty); } var review = dataHolder.AddDocument(); foreach (var record in parsed.WordsTable) { var addedRecord = review.AddRecord(record.Key); if (addedRecord != null) { addedRecord.Value = record.Value; } } await Task.Run(() => testClient.Classify(dataHolder)).ConfigureAwait(false); return(review.Class.Value as string); }
public async Task <MemoryStream> Handle(GenerateDocumentFromTemplate request, CancellationToken cancellationToken) { var documentPath = Path.Combine(DocumentConsts.TemplatesFolder, request.DocumentTemplateName); var parsedDocument = await _documentParser.ParseDocument(request.DocumentPositionKeyValues, documentPath); parsedDocument.Position = 0; return(parsedDocument); }
private async Task <DocumentDefinition> ParseDocument(DirectoryInfo repositoryPath, string file) { try { return(await parser.ParseDocument(repositoryPath, new FileInfo(file), token).ConfigureAwait(false)); } catch (Exception ex) { logger.Error(ex); throw; } finally { if (!token.IsCancellationRequested) { var current = Interlocked.Increment(ref totalProcessed); progressUpdate.OnNext(new ProcessingProgress(current, total)); } } }