public static IEnumerable <Selection> Handle(Selection selection, FilterQueryUnsupportedParserFeature query, string output = null, AbstractTableWriter writer = null) { return(query.MetaLabel == "<:RANDOM:>" ? UnsupportedParserRandomFeature(selection, query, output, writer) : UnsupportedParserFeatureAutosplit(selection, query, output, writer)); }
private static IEnumerable <Selection> UnsupportedParserFeatureAutosplit( Selection selection, FilterQueryUnsupportedParserFeature query, string output, AbstractTableWriter writer) { var values = query.MetaValues?.ToArray(); if (values?.Length != 1) { return(null); } var selections = AutoSplitBlockHelper.RunAutoSplit(selection, query, values); return(string.IsNullOrEmpty(output) ? selections : UnsupportedParserFeatureAutosplitToFile(writer, output, selections)); }
private static IEnumerable <Selection> UnsupportedParserRandomFeature( Selection selection, FilterQueryUnsupportedParserFeature query, string output, AbstractTableWriter writer) { var values = query.MetaValues?.ToArray(); if (values?.Length != 1) { return(null); } var block = selection.CreateBlock <RandomSelectionBlock>(); var value = values[0].ToString(); if (value.EndsWith("%%%")) { block.DocumentMaxProMillion = double.Parse(value.Replace("%%%", "")); } else if (value.EndsWith("%")) { block.DocumentMaxPercent = double.Parse(value.Replace("%", "")); } else if (value.EndsWith("T")) { block.TokenMax = long.Parse(value.Replace("T", "")); } else if (value.EndsWith("TTT")) { block.TokenMax = (long)(double.Parse(value.Replace("TTT", "")) * 1000000); } else { block.DocumentMaxCount = int.Parse(value); } block.Calculate(); return(string.IsNullOrEmpty(output) ? UnsupportedParserRandomFeatureToObject(block) : UnsupportedParserRandomFeatureToFile(writer, output, block)); }