diff --git a/TextParser/Data/DataManipulationHelpers.cs b/TextParser/Data/DataManipulationHelpers.cs index 68218a2..408a39c 100644 --- a/TextParser/Data/DataManipulationHelpers.cs +++ b/TextParser/Data/DataManipulationHelpers.cs @@ -20,4 +20,24 @@ public static class DataManipulationHelpers { return reducer(data); } + + public static List TransformData(this List data, Func transformer) + { + var newList = new List(); + foreach (TType dataItem in data) + { + newList.Add(transformer(dataItem)); + } + return newList; + } + + public static List TransformData(this List> data, Func, TNewType> transformer) + { + var newList = new List(); + foreach (List dataItemList in data) + { + newList.Add(transformer(dataItem)); + } + return newList; + } } \ No newline at end of file diff --git a/TextParser/Data/TokenConverter.cs b/TextParser/Data/TokenConverter.cs index 5cd7fe4..33f5753 100644 --- a/TextParser/Data/TokenConverter.cs +++ b/TextParser/Data/TokenConverter.cs @@ -156,4 +156,21 @@ public class TokenConverter return newList; } + + public TokenConverter Filter(params InputType[] inputTypes) + { + var newTokenList = new List>() + + foreach(var token in rawTokens) + { + if(inputTypes.Contains(token.GetInputType())) + { + newTokenList.Add(token); + } + } + + this.rawTokens = newTokenList; + + return this; + } }