3 instantiations of NGram
Microsoft.Extensions.AI.Evaluation.NLP (3)
Common\NGramExtensions.cs (3)
14where T : IEquatable<T> => new(values); 39nGrams.Add(new NGram<T>(next)); 78nGrams.Add(new NGram<T>(input.Slice(i, s)));
19 references to NGram
Microsoft.Extensions.AI.Evaluation.NLP (19)
Common\BLEUAlgorithm.cs (6)
70List<NGram<string>> hypGrams = hypothesis.CreateNGrams(n); 71MatchCounter<NGram<string>> hypCounts = new(hypGrams); 73Dictionary<NGram<string>, int> maxCounts = []; 77List<NGram<string>> refGrams = rf.CreateNGrams(n); 78MatchCounter<NGram<string>> refCounts = new(refGrams); 93Dictionary<NGram<string>, int> clippedCounts = [];
Common\GLEUAlgorithm.cs (3)
28MatchCounter<NGram<string>> hypNGrams = new(hypothesis.CreateAllNGrams(minN, maxN)); 34MatchCounter<NGram<string>> refNGrams = new(reference.CreateAllNGrams(minN, maxN)); 37MatchCounter<NGram<string>> overlapNGrams = hypNGrams.Intersect(refNGrams);
Common\NGram.cs (3)
16internal readonly struct NGram<T> : IEquatable<NGram<T>>, IEnumerable<T> 34public bool Equals(NGram<T> other) 37public override bool Equals(object? obj) => obj is NGram<T> other && Equals(other);
Common\NGramExtensions.cs (7)
13public static NGram<T> CreateNGram<T>(this ReadOnlySpan<T> values) 16internal static List<NGram<T>> CreateNGrams<T>(this T[] input, int n) 25internal static List<NGram<T>> CreateNGrams<T>(this ReadOnlySpan<T> input, int n) 33List<NGram<T>> nGrams = []; 48internal static List<NGram<T>> CreateAllNGrams<T>(this T[] input, int minN, int maxN = -1) 58internal static List<NGram<T>> CreateAllNGrams<T>(this ReadOnlySpan<T> input, int minN, int maxN = -1) 72List<NGram<T>> nGrams = [];