public async Task <Document> InitDocument(string name = "cv000_29416.txt") { var result = await helper.GetTextSplitter().Process(new ParseRequest(File.ReadAllText(Path.Combine(path, name)))).ConfigureAwait(false); var factory = helper.Resolve <IWordFactory>(); var document = result.Construct(factory); var review = helper.Resolve <Func <Document, IParsedReviewManager> >()(document).Create(); var documentFromReview = new DocumentFromReviewFactory(); return(documentFromReview.ReparseDocument(new NullRatingAdjustment(review))); }
private static IEnumerable <IParsedDocumentHolder> GetReview(ISessionContainer container, string path, double?stars) { if (File.Exists(path)) { foreach (var line in File.ReadLines(path)) { yield return(new ParsingDocumentHolder(container.GetTextSplitter(), container.GetWordFactory(), container.Resolve <IContextSentenceRepairHandler>(), new Document(line.SanitizeXmlString()) { Stars = stars })); } } else { foreach (var file in Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories)) { yield return(new AsyncParsingDocumentHolder(Task.Run(() => { var fileInfo = new FileInfo(file); var document = new Document(File.ReadAllText(file).SanitizeXmlString()) { Id = $"{fileInfo.Directory.Name}_{Path.GetFileNameWithoutExtension(fileInfo.Name)}", Stars = stars }; return (IParsedDocumentHolder) new ParsingDocumentHolder(container.GetTextSplitter(), container.GetWordFactory(), container.Resolve <IContextSentenceRepairHandler>(), document); }))); } } }
private static async Task <IParsedDocumentHolder> ConstructHolder(ISessionContainer container, DataPair processingData) { var result = await processingData.Data.ConfigureAwait(false); if (processingData.Sentiment == SentimentClass.Positive) { SetStars(result, 5); } else if (processingData.Sentiment == SentimentClass.Negative) { SetStars(result, 1); } return(new ParsingDocumentHolder(container.GetTextSplitter(), container.GetWordFactory(), container.Resolve <IContextSentenceRepairHandler>(), result)); }