public static Dictionary <string, CountData> CreateIDFdic(CountDic dic, int docNum) { return(dic.Dic.Select(n => new CountData() { Word = n.Key, Count = n.Value, Value = Math.Log(docNum / (double)(n.Value + 1)) }).ToDictionary(n => n.Word)); }
public void Cut(int p) { CountDic cdic = new CountDic(); foreach (var item in docDic.Values.SelectMany(n => n.WordDic)) { cdic.Add(item.Key, item.Value.Count); } var list = cdic.Dic.Where(n => n.Value < p).Select(n => n.Key).ToArray(); foreach (var item in docDic) { item.Value.Cut(list); } }
public static Dictionary<string, CountData> CreateIDFdic(CountDic dic,int docNum) { return dic.Dic.Select(n => new CountData() { Word = n.Key, Count = n.Value, Value = Math.Log(docNum / (double)(n.Value + 1)) }).ToDictionary(n => n.Word); }
public void Cut(int p) { CountDic cdic = new CountDic(); foreach (var item in docDic.Values.SelectMany(n=>n.WordDic)) { cdic.Add(item.Key, item.Value.Count); } var list = cdic.Dic.Where(n => n.Value < p).Select(n => n.Key).ToArray(); foreach (var item in docDic) { item.Value.Cut(list); } }