Skip to content

Commit

Permalink
small interface refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Dermody committed Nov 25, 2024
1 parent c550602 commit 3213321
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 10 deletions.
77 changes: 73 additions & 4 deletions BrightData/BrightData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4385,7 +4385,7 @@
<param name="weight">Weight to give each index</param>
<returns></returns>
</member>
<member name="M:BrightData.ExtensionMethods.ConvertToWeightedIndexList``1(System.Collections.Generic.IReadOnlyList{BrightData.IndexListWithLabel{``0}},System.Boolean)">
<member name="M:BrightData.ExtensionMethods.ConvertToWeightedIndexList``1(System.Collections.Generic.IEnumerable{BrightData.IndexListWithLabel{``0}},System.Boolean)">
<summary>
Converts the indexed classifications to weighted indexed classifications
</summary>
Expand Down Expand Up @@ -4417,14 +4417,14 @@
<param name="data"></param>
<returns></returns>
</member>
<member name="M:BrightData.ExtensionMethods.TfIdf``1(System.Collections.Generic.IReadOnlyList{BrightData.WeightedIndexListWithLabel{``0}})">
<member name="M:BrightData.ExtensionMethods.TfIdf``1(System.Collections.Generic.IReadOnlyCollection{BrightData.WeightedIndexListWithLabel{``0}})">
<summary>
Modifies the weights in the classification set based on relative corpus statistics to increase the weight of important words relative to each document
https://en.wikipedia.org/wiki/Tf%E2%80%93idf
</summary>
<returns>A newly weighted classification set</returns>
</member>
<member name="M:BrightData.ExtensionMethods.Bm25Plus``1(System.Collections.Generic.IReadOnlyList{BrightData.WeightedIndexListWithLabel{``0}},System.Single,System.Single,System.Single)">
<member name="M:BrightData.ExtensionMethods.Bm25Plus``1(System.Collections.Generic.IReadOnlyCollection{BrightData.WeightedIndexListWithLabel{``0}},System.Single,System.Single,System.Single)">
<summary>
Okapi B525+ modifies the weights in the classification set based on relative corpus statistics to increase the weight of important words relative to each document
https://en.wikipedia.org/wiki/Okapi_BM25
Expand Down Expand Up @@ -5479,6 +5479,16 @@
<typeparam name="AT"></typeparam>
<returns></returns>
</member>
<member name="M:BrightData.ExtensionMethods.MultiBinarySearch``2(System.ReadOnlySpan{``0},``1)">
<summary>
Multi
</summary>
<param name="span"></param>
<param name="comparator"></param>
<typeparam name="T"></typeparam>
<typeparam name="CT"></typeparam>
<returns></returns>
</member>
<member name="M:BrightData.ExtensionMethods.ToReadOnlyVector``1(System.ReadOnlySpan{``0})">
<summary>
Creates a read only vector from the span
Expand Down Expand Up @@ -6351,6 +6361,13 @@
</summary>
<param name="span"></param>
</member>
<member name="M:BrightData.Helper.SpanAggregator`1.Add(System.ReadOnlySpan{`0},`0)">
<summary>
Adds a new operation
</summary>
<param name="span"></param>
<param name="coefficient"></param>
</member>
<member name="P:BrightData.Helper.SpanAggregator`1.Span">
<summary>
The aggregation result
Expand Down Expand Up @@ -7210,6 +7227,58 @@
String indexer
</summary>
</member>
<member name="T:BrightData.IStringTableInMemory">
<summary>
In memory string table
</summary>
</member>
<member name="M:BrightData.IStringTableInMemory.GetUtf8(System.UInt32)">
<summary>
Gets a string as utf-8
</summary>
<param name="index"></param>
<returns></returns>
</member>
<member name="M:BrightData.IStringTableInMemory.GetString(System.UInt32)">
<summary>
Gets a string by index
</summary>
<param name="index"></param>
<returns></returns>
</member>
<member name="M:BrightData.IStringTableInMemory.GetAll(System.Int32)">
<summary>
Gets all strings
</summary>
<param name="maxStringSize">Max string size</param>
<returns></returns>
</member>
<member name="T:BrightData.IAsyncStringTable">
<summary>
Asynchronous string table
</summary>
</member>
<member name="M:BrightData.IAsyncStringTable.GetUtf8(System.UInt32)">
<summary>
Gets a string as utf-8
</summary>
<param name="index"></param>
<returns></returns>
</member>
<member name="M:BrightData.IAsyncStringTable.GetString(System.UInt32)">
<summary>
Gets a string by index
</summary>
<param name="index"></param>
<returns></returns>
</member>
<member name="M:BrightData.IAsyncStringTable.GetAll(System.Int32)">
<summary>
Gets all strings
</summary>
<param name="maxStringSize">Max string size</param>
<returns></returns>
</member>
<member name="T:BrightData.INotifyOperationProgress">
<summary>
Notifies of operations and messages
Expand Down Expand Up @@ -13106,7 +13175,7 @@
<param name="memory"></param>
<returns></returns>
</member>
<member name="M:BrightData.LinearAlgebra.VectorIndexing.VectorSet`1.Add(System.Collections.Generic.IReadOnlyList{BrightData.IReadOnlyVector{`0}})">
<member name="M:BrightData.LinearAlgebra.VectorIndexing.VectorSet`1.Add(System.Collections.Generic.IReadOnlyCollection{BrightData.IReadOnlyVector{`0}})">
<summary>
Adds a collection of vectors to the set
</summary>
Expand Down
6 changes: 3 additions & 3 deletions BrightData/ExtensionMethods.IndexList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static WeightedIndexList CreateWeightedIndexList(this BrightDataContext _
/// <param name="data"></param>
/// <param name="groupByClassification">True to group by classification (i.e. convert the bag to a set)</param>
public static WeightedIndexListWithLabel<T>[] ConvertToWeightedIndexList<T>(
this IReadOnlyList<IndexListWithLabel<T>> data,
this IEnumerable<IndexListWithLabel<T>> data,
bool groupByClassification
)
{
Expand Down Expand Up @@ -184,7 +184,7 @@ public static WeightedIndexListWithLabel<T>[] Normalize<T>(this Span<WeightedInd
/// https://en.wikipedia.org/wiki/Tf%E2%80%93idf
/// </summary>
/// <returns>A newly weighted classification set</returns>
public static WeightedIndexListWithLabel<T>[] TfIdf<T>(this IReadOnlyList<WeightedIndexListWithLabel<T>> data) where T: notnull
public static WeightedIndexListWithLabel<T>[] TfIdf<T>(this IReadOnlyCollection<WeightedIndexListWithLabel<T>> data) where T: notnull
{
int len = data.Count, i = 0;
var ret = new WeightedIndexListWithLabel<T>[len];
Expand Down Expand Up @@ -216,7 +216,7 @@ public static WeightedIndexListWithLabel<T>[] TfIdf<T>(this IReadOnlyList<Weight
/// https://en.wikipedia.org/wiki/Okapi_BM25
/// </summary>
/// <returns>Newly weighted classification set</returns>
public static WeightedIndexListWithLabel<T>[] Bm25Plus<T>(this IReadOnlyList<WeightedIndexListWithLabel<T>> data, float k = 1.2f, float b = 0.75f, float d = 1f) where T : notnull
public static WeightedIndexListWithLabel<T>[] Bm25Plus<T>(this IReadOnlyCollection<WeightedIndexListWithLabel<T>> data, float k = 1.2f, float b = 0.75f, float d = 1f) where T : notnull
{
int len = data.Count, i = 0;
var ret = new WeightedIndexListWithLabel<T>[len];
Expand Down
7 changes: 4 additions & 3 deletions BrightData/LinearAlgebra/VectorIndexing/VectorSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,12 @@ public uint Add(IReadOnlyNumericSegment<T> segment)
/// </summary>
/// <param name="vectors"></param>
/// <returns></returns>
public uint[] Add(IReadOnlyList<IReadOnlyVector<T>> vectors)
public uint[] Add(IReadOnlyCollection<IReadOnlyVector<T>> vectors)
{
var ret = new uint[vectors.Count];
for (var i = 0; i < ret.Length; i++)
ret[i] = Add(vectors[i]);
var index = 0;
foreach(var item in vectors)
ret[index++] = Add(item);
return ret;
}

Expand Down

0 comments on commit 3213321

Please sign in to comment.