public void BuildSegmentTable(int n) { if(_segmentTable == null) _segmentTable = new NGramCache(); foreach (var item in Documents) { var array = item.LanguageSegments.ToArray(); for (int i = 0; i <= array.Length - n; i++) { _segmentTable.Increment(array.GetNGram(i, n), 1); // inc count } } }
public static NGramCache Aggregate(IEnumerable<NGramCache> nGramCaches) { var result = new NGramCache(); foreach (var item in nGramCaches) { IEnumerable<NGramCache> nGrams = item.NextSegment.Values; while(nGrams.Count() > 0) { foreach (var xGram in nGrams) { result.Increment(xGram.NGram, xGram.Value); } // next n nGrams = nGrams.SelectMany(el => el.NextSegment.Values); } } return result; }
public static NGramCache Aggregate(IEnumerable <NGramCache> nGramCaches) { var result = new NGramCache(); foreach (var item in nGramCaches) { IEnumerable <NGramCache> nGrams = item.NextSegment.Values; while (nGrams.Count() > 0) { foreach (var xGram in nGrams) { result.Increment(xGram.NGram, xGram.Value); } // next n nGrams = nGrams.SelectMany(el => el.NextSegment.Values); } } return(result); }
public void SetNGramCache(NGramCache value) { _segmentTable = value; }