/// <summary> /// Runs the content parsing part of the summarizing algorithm /// </summary> /// <param name="contentProvider"></param> /// <param name="contentParser"></param> /// <returns></returns> public ParsedDocument ParseContent(IContentProvider contentProvider, IContentParser contentParser) { if (contentProvider == null) { throw new ArgumentNullException("contentProvider"); } if (contentParser == null) { throw new ArgumentNullException("contentParser"); } var resultingParsedDocument = new ParsedDocument(); resultingParsedDocument.Sentences = contentParser.SplitContentIntoSentences(contentProvider.Content); if (resultingParsedDocument.Sentences == null) { throw new InvalidOperationException(string.Format("{0}.SplitContentIntoSentences must not return null", contentProvider.GetType().FullName)); } foreach (var workingSentence in resultingParsedDocument.Sentences) { workingSentence.TextUnits = contentParser.SplitSentenceIntoTextUnits(workingSentence.OriginalSentence); if (workingSentence.TextUnits == null) { throw new InvalidOperationException(string.Format("{0}.SplitSentenceIntoTextUnits must not return null", contentProvider.GetType().FullName)); } } return(resultingParsedDocument); }
public void before_each_test_setup() { TargetContentProvider = Substitute.For <IContentProvider>(); TargetContentProvider.Content.Returns(Content); TargetContentParser = Substitute.For <IContentParser>(); TargetContentParser.SplitContentIntoSentences(Arg.Any <string>()).Returns( new List <Sentence> { new Sentence { OriginalSentence = Sentence1 }, new Sentence { OriginalSentence = Sentence2 } } ); TargetContentParser.SplitSentenceIntoTextUnits(Arg.Any <string>()).Returns( new List <TextUnit> { new TextUnit { RawValue = Content } } ); }
public DockerGraphFactory( [NotNull] IContentParser contentParser, [NotNull] IPathService pathService) { _contentParser = contentParser ?? throw new ArgumentNullException(nameof(contentParser)); _pathService = pathService ?? throw new ArgumentNullException(nameof(pathService)); }
/// <summary> /// Runs the content parsing part of the summarizing algorithm /// </summary> /// <param name="contentProvider"></param> /// <param name="contentParser"></param> /// <returns></returns> public ParsedDocument ParseContent(IContentProvider contentProvider, IContentParser contentParser) { if (contentProvider == null) { throw new ArgumentNullException(nameof(contentProvider)); } if (contentParser == null) { throw new ArgumentNullException(nameof(contentParser)); } var resultingParsedDocument = new ParsedDocument { Sentences = contentParser .SplitContentIntoSentences(contentProvider.Content) .Where(sentence => !string.IsNullOrWhiteSpace(sentence.OriginalSentence)) .ToList() }; foreach (Sentence workingSentence in resultingParsedDocument.Sentences) { workingSentence.TextUnits = contentParser .SplitSentenceIntoTextUnits(workingSentence.OriginalSentence) .Where(word => !string.IsNullOrWhiteSpace(word.RawValue)) .ToList(); } return(resultingParsedDocument); }
/// <summary> /// Runs the content parsing part of the summarizing algorithm /// </summary> /// <param name="contentProvider"></param> /// <param name="contentParser"></param> /// <returns></returns> public ParsedDocument ParseContent(IContentProvider contentProvider, IContentParser contentParser) { if (contentProvider == null) { throw new ArgumentNullException(nameof(contentProvider)); } if (contentParser == null) { throw new ArgumentNullException(nameof(contentParser)); } var resultingParsedDocument = new ParsedDocument { Sentences = contentParser.SplitContentIntoSentences(contentProvider.Content) }; if (resultingParsedDocument.Sentences == null) { throw new InvalidOperationException( $"{contentProvider.GetType().FullName}.SplitContentIntoSentences must not return null"); } foreach (var workingSentence in resultingParsedDocument.Sentences) { workingSentence.TextUnits = contentParser.SplitSentenceIntoTextUnits(workingSentence.OriginalSentence); if (workingSentence.TextUnits == null) { throw new InvalidOperationException( $"{contentProvider.GetType().FullName}.SplitSentenceIntoTextUnits must not return null"); } } return resultingParsedDocument; }
/// <summary> /// Runs the content parsing part of the summarizing algorithm /// </summary> /// <param name="contentProvider"></param> /// <param name="contentParser"></param> /// <returns></returns> public ParsedDocument ParseContent(IContentProvider contentProvider, IContentParser contentParser) { if (contentProvider == null) { throw new ArgumentNullException(nameof(contentProvider)); } if (contentParser == null) { throw new ArgumentNullException(nameof(contentParser)); } ParsedDocument resultingParsedDocument = new ParsedDocument { Sentences = contentParser.SplitContentIntoSentences(contentProvider.Content) }; if (resultingParsedDocument.Sentences == null) { throw new InvalidOperationException($"{contentProvider.GetType().FullName}.SplitContentIntoSentences must not return null"); } foreach (Sentence workingSentence in resultingParsedDocument.Sentences) { workingSentence.TextUnits = contentParser.SplitSentenceIntoTextUnits(workingSentence.OriginalSentence); if (workingSentence.TextUnits == null) { throw new InvalidOperationException($"{contentProvider.GetType().FullName}.SplitSentenceIntoTextUnits must not return null"); } } return(resultingParsedDocument); }
public BoundRequestController( Context context, TRequestController requestController, IContentParser contentParser) { _requestController = requestController; _context = context; _contentParser = contentParser; }
public SdnItemsProcessingService(ISdnRepository sdnRepository, IContentDownloader contentDownloader, IContentParser contentParser, ILogger logger) { _sdnRepository = sdnRepository; _contentDownloader = contentDownloader; _contentParser = contentParser; _logger = logger; }
public async Task HandleAsync(WorkerOperation operation) { IContentParser <IEnumerable <TDto> > parser = this.contentParser.FirstOrDefault(p => p.ContentType == operation.ContentType); if (parser == null) { //TODO handler null parser } TDto[] dtos = parser.Parse(operation.Content).ToArray(); var failureReasons = new List <string>(); for (int i = 0; i < dtos.Length; i++) { TDto dto = dtos[i]; if (!IsValid(dto, out string reason)) { failureReasons.Add($"Validation error processing row {i + 1}. {reason}."); continue; } try { var enrichers = new List <Task>(); foreach (IEnricher <TDto> enricher in this.enrichers) { enrichers.Add(enricher.EnrichAsync(dto)); } await Task.WhenAll(enrichers); } catch (Exception ex) { this.logger.LogError(ex, $"Failed to process row {i + 1} while running enricher.", new { operation.Id, operation.JobId, operation.ContentType, operation.Entity }, dto); failureReasons.Add($"Failed to process row {i + 1}."); } await this.repository.CreateAsync(CreateDomainEntity(dto, operation.Body)); } if (failureReasons.Count > 0) { await this.workerOperationStatusRepository.CreateAsync(operation, failureReasons); } }
public ContentParseUnitTest() { // configure services injection. var serviceProvider = new ServiceCollection() .AddLogging() .AddSingleton <IContentParser, ContentParser>() .BuildServiceProvider(); _fakeContents = new Faker(); _logger = serviceProvider .GetService <ILoggerFactory>() .CreateLogger(typeof(ContentParseUnitTest)); // get required service _contentParserService = serviceProvider.GetService <IContentParser>(); }
public FileSystemOutputHandler( CommandLineOptions commandLineOptions, IFileSystem fileSystem, IContext <Post, Tag, Page> context, ITemplateHandler templateHandler, IContentParser contentParser, IOptions <SiteConfig> siteConfig, ISourceHandler sourceHandler, ISlugHelper slugHelper) { (this.commandLineOptions, this.fileSystem, this.context, this.templateHandler, this.contentParser, this.siteConfig, this.sourceHandler, this.slugHelper) = (commandLineOptions, fileSystem, context, templateHandler, contentParser, siteConfig.Value, sourceHandler, slugHelper); this.site = new { config = this.siteConfig, tags = this.context.Tags.OrderBy(t => t.Name), pages = this.context.Pages }; }
public MSMQQueue(IContentParser parser, IConfigurationSource cfg, ILogger logger) : base(parser, cfg, logger) { }
public HomeController(ILogger <HomeController> logger, IContentParser contentParser) { _logger = logger; _contentParser = contentParser; }
public void throws_if_null_arguments_are_passed(IContentProvider contentProvider, IContentParser contentParser) { Assert.Throws<ArgumentNullException>(() => Target.ParseContent(contentProvider, contentParser)); }
public void throws_if_null_arguments_are_passed(IContentProvider contentProvider, IContentParser contentParser) { Assert.That(() => Target.ParseContent(contentProvider, contentParser), Throws.TypeOf <ArgumentNullException>()); }
public void throws_if_null_arguments_are_passed(IContentProvider contentProvider, IContentParser contentParser) { Target.ParseContent(contentProvider, contentParser); }
public HttpMessageSource(IContentParser parser, IConfigurationSource cfg, ILogger logger) : base(parser, cfg, logger) { Messages = new ConcurrentQueue<IMessage>(); }
public FileConverter(IFileReader fileReader, IContentParser contentParser) { _fileReader = fileReader; _contentParser = contentParser; }
protected BaseMessageSource(IContentParser parser, IConfigurationSource cfg, ILogger logger) { Parser = parser; Configuration = cfg; Logger = logger; }
public HttpMessageSource(IContentParser parser, IConfigurationSource cfg, ILogger logger) : base(parser, cfg, logger) { Messages = new ConcurrentQueue <IMessage>(); }
public ProcessingWorker(IPostRepository repository, IContentParser <Post> contentParser) { _repository = repository; _contentParser = contentParser; }
public BaseParser(IContentParser parser) { _contextParser = parser; }
public WebsiteScraper(IContentParser contentParser) { _contentParser = contentParser; }