public ExtractFeatureBlock(ExtractBlock block, string feature = "") { this.Block = block; var selectors = new List <ISelector>(); if (string.IsNullOrEmpty(feature)) { return; } var sp = feature.Replace("\r\n", "\n").Split('\n'); foreach (var s in sp) { var selector = RuiJiBlockParser.ParserSelector(s); selectors.Add(selector); } ExtractFeature = new ExtractFeature(); ExtractFeature.Feature = selectors; }
/// <summary> /// Extract by ExtractRequest /// </summary> /// <param name="request">ExtractRequest</param> /// <returns>ExtractResult list</returns> public static List <ExtractResult> Extract(ExtractRequest request) { if (request.Blocks == null) { return(new List <ExtractResult>()); } var blocks = request.Blocks.Where(m => m.ExtractFeature != null && m.ExtractFeature.Features != null && m.ExtractFeature.Features.Count > 0).OrderByDescending(m => m.ExtractFeature.Features.Count).ToList(); var results = new List <ExtractResult>(); foreach (var block in blocks) { var b = new ExtractBlock(); b.Selectors = block.ExtractFeature.Features; var r = Extract(request.Content, b); if (r.Content.ToString().Length > 0) { r = Extract(request.Content, block.Block); results.Add(r); break; } } if (results.Count > 0) { return(results); } blocks = request.Blocks.Where(m => m.ExtractFeature == null || m.ExtractFeature.Features == null || m.ExtractFeature.Features.Count == 0).ToList(); foreach (var block in blocks) { results.Add(Extract(request.Content, block.Block)); } return(results); }