5 Commits

Author SHA1 Message Date
e83e99758a feat: add filter option to TokenConverter, ref: NOISSUE 2024-12-13 13:13:43 +01:00
81ac797b4c release: version 0.8.0 🚀
Some checks failed
Upload Python Package / Create Release (push) Successful in 17s
Upload Python Package / deploy (push) Failing after 4m6s
2024-12-12 20:03:14 +01:00
e9aa60524c feat: adding sensible index constructors refs: NOISSUE 2024-12-12 20:03:07 +01:00
7e5ab9f799 release: version 0.7.2 🚀
Some checks failed
Upload Python Package / Create Release (push) Successful in 17s
Upload Python Package / deploy (push) Failing after 4m24s
2024-12-06 00:33:43 +01:00
fc137ebd03 fix: add some missing API methods, ref: NOISSUE 2024-12-06 00:33:37 +01:00
7 changed files with 79 additions and 11 deletions

View File

@@ -4,12 +4,32 @@ Changelog
(unreleased) (unreleased)
------------ ------------
- Feat: adding sensible index constructors refs: NOISSUE. [Simon
Diesenreiter]
0.7.2 (2024-12-05)
------------------
Fix
~~~
- Add some missing API methods, ref: NOISSUE. [Simon Diesenreiter]
Other
~~~~~
0.7.1 (2024-12-05)
------------------
Fix Fix
~~~ ~~~
- Allow for parsing single chars as input, ref: NOISSUE. [Simon - Allow for parsing single chars as input, ref: NOISSUE. [Simon
Diesenreiter] Diesenreiter]
Other
~~~~~
0.7.0 (2024-12-05) 0.7.0 (2024-12-05)
------------------ ------------------

View File

@@ -20,4 +20,24 @@ public static class DataManipulationHelpers
{ {
return reducer(data); return reducer(data);
} }
public static List<TNewType> TransformData<TType, TNewType>(this List<TType> data, Func<TType, TNewType> transformer)
{
var newList = new List<TNewType>();
foreach (TType dataItem in data)
{
newList.Add(transformer(dataItem));
}
return newList;
}
public static List<TNewType> TransformData<TType, TNewType>(this List<List<TType>> data, Func<List<TType>, TNewType> transformer)
{
var newList = new List<TNewType>();
foreach (List<TType> dataItemList in data)
{
newList.Add(transformer(dataItem));
}
return newList;
}
} }

View File

@@ -4,11 +4,22 @@ namespace Parsing.Data;
public class SearchResult<TIndexType> public class SearchResult<TIndexType>
{ {
public SearchResult(IDataIndex<TIndexType> dataIndex)
{
this.DataIndex = dataIndex;
}
public IDataIndex<TIndexType>? DataIndex { get; set; } public IDataIndex<TIndexType>? DataIndex { get; set; }
} }
public class DirectionalSearchResult<TIndexType> : SearchResult<TIndexType> public class DirectionalSearchResult<TIndexType> : SearchResult<TIndexType>
{ {
public DirectionalSearchResult(IDataIndex<TIndexType> dataIndex, Direction direction, int length): base(dataIndex)
{
this.Direction = direction;
this.Length = length;
}
public Direction Direction { get; set; } public Direction Direction { get; set; }
public int Length { get; set; } public int Length { get; set; }
} }
@@ -111,10 +122,7 @@ public abstract class DataSetManipulatorBase<TCollectedType, TDataType, TIndexTy
} }
if (searchIndex == data.Count) if (searchIndex == data.Count)
{ {
var result = new DirectionalSearchResult<TIndexType>(); var result = new DirectionalSearchResult<TIndexType>(currentPosition, direction, searchIndex);
result.DataIndex = currentPosition;
result.Direction = direction;
result.Length = searchIndex;
results.Add(result); results.Add(result);
} }
} }
@@ -123,7 +131,7 @@ public abstract class DataSetManipulatorBase<TCollectedType, TDataType, TIndexTy
return results; return results;
} }
public List<DirectionalSearchResult<TIndexType>> FindInSet(List<TDataType> data) public List<DirectionalSearchResult<TIndexType>> FindInSet(List<TDataType> data, Direction directions)
{ {
var result = new List<DirectionalSearchResult<TIndexType>>(); var result = new List<DirectionalSearchResult<TIndexType>>();
@@ -131,11 +139,16 @@ public abstract class DataSetManipulatorBase<TCollectedType, TDataType, TIndexTy
var startingPoints = this.FindInSet(data[0]); var startingPoints = this.FindInSet(data[0]);
foreach (var startingPoint in startingPoints) foreach (var startingPoint in startingPoints)
{ {
foreach (var results in this.FindAtPosition(startingPoint.DataIndex, data)) foreach (var results in this.FindAtPosition(startingPoint.DataIndex, data, directions))
{ {
result.AddRange(results); result.AddRange(results);
} }
} }
return result; return result;
} }
public List<DirectionalSearchResult<TIndexType>> FindInSet(List<TDataType> data)
{
return this.FindInSet(data, this.ValidDirections());
}
} }

View File

@@ -49,8 +49,7 @@ public class DefaultOneDimensionalManipulator<TDataType> : DataSetManipulatorBas
{ {
if (EqualityComparer<TDataType>.Default.Equals(this.dataSet[i], data)) if (EqualityComparer<TDataType>.Default.Equals(this.dataSet[i], data))
{ {
var singleResult = new SearchResult<int>(); var singleResult = new SearchResult<int>(new DefaultPositionalDataIndex(i));
singleResult.DataIndex = new DefaultPositionalDataIndex(i);
results.Add(singleResult); results.Add(singleResult);
} }
} }

View File

@@ -71,8 +71,7 @@ public class DefaultTwoDimensionalManipulator<TDataType> : DataSetManipulatorBas
{ {
if (EqualityComparer<TDataType>.Default.Equals(this.dataSet[this.dataSet.Count - y - 1][x], data)) if (EqualityComparer<TDataType>.Default.Equals(this.dataSet[this.dataSet.Count - y - 1][x], data))
{ {
var singleResult = new SearchResult<int>(); var singleResult = new SearchResult<int>(new DefaultPositionalDataIndex(x, y));
singleResult.DataIndex = new DefaultPositionalDataIndex(x, y);
results.Add(singleResult); results.Add(singleResult);
} }
} }

View File

@@ -156,4 +156,21 @@ public class TokenConverter
return newList; return newList;
} }
public TokenConverter Filter<T>(params InputType[] inputTypes)
{
var newTokenList = new List<List<IToken>>()
foreach(var token in rawTokens)
{
if(inputTypes.Contains(token.GetInputType()))
{
newTokenList.Add(token);
}
}
this.rawTokens = newTokenList;
return this;
}
} }

View File

@@ -1 +1 @@
0.7.1 0.8.0