public async Task HandleAsync(IDispatcher dispatcher, ICommandContext <TranslateEducationCommand> context) { var content = await _downloader.GetProfile(context.Command.EducationId); var contentToTranslate = _textExtractor.ExtractText(content); var translations = new List <string>(); foreach (var text in contentToTranslate) { var translatedText = await _translator.TranslateText(text, context.Command.ToLanguage); translations.Add(translatedText); } var fileKey = GenerateKey(context.Command); await _persister.PersistTranslations(fileKey, translations); await dispatcher.RaiseEventAsync(new EducationTranslatedEvent { EducationId = context.Command.EducationId, ToLanguage = context.Command.ToLanguage, TranslationFileKey = fileKey }); }
public IndexedDocument(DocumentModel uploadedDocument, User user, DocumentIndexator documentIndexator) { var uploadedFile = uploadedDocument.File; FileName = Path.GetFileNameWithoutExtension(uploadedFile.FileName); CreatedDate = DateTime.Now; UserId = user.Id; ITextExtractor textExtractor = TextExtractorFactory.GetTextExtractor(uploadedDocument.DocumentExtension); Content = textExtractor.ExtractText(uploadedDocument); WordFrequency = documentIndexator.ExtractWordFrequency(Content + ' ' + FileName); }