public override bool Equals(object o) { if (o is NgramContainer <T> ) { NgramContainer <T> testObj = (NgramContainer <T>)o; return(Ngrams.OrderBy(a => a).ToArray().SequenceEqual(testObj.Ngrams.OrderBy(a => a).ToArray())); } return(false); }
internal StateStatistic(NgramContainer <TGram> state, IEnumerable <TGram> valuesAtState) { State = state.Ngrams; var groupedValues = valuesAtState.GroupBy(x => x).ToList(); Next = groupedValues.Select(a => new NgramStatistic <TGram> { Value = a.Key, Count = a.Count(), Probability = Math.Round(((double)a.Count() / (double)groupedValues.Sum(x => x.Count())) * 100, 2) }).OrderByDescending(x => x.Probability); }
/// <summary> /// Add a TGram to the markov models store with a composite key of the previous [Level] number of TGrams /// </summary> /// <param name="key">The composite key under which to add the TGram value</param> /// <param name="value">The value to add to the store</param> internal void AddOrCreate(NgramContainer <T> key, T value) { lock (_lockObj) { if (!ChainDictionary.ContainsKey(key)) { ChainDictionary.TryAdd(key, new List <T> { value }); } else { ChainDictionary[key].Add(value); } } }
internal List <T> GetValuesForKey(NgramContainer <T> key) { return(ChainDictionary[key]); }
internal bool Contains(NgramContainer <T> key) { return(ChainDictionary.ContainsKey(key)); }