public static string ShowKeyBondCollEx(KeyBondColl <string, string> objKeyBondColl, List <string> objKeyWordList, int nLinkTopCount, bool bIsOrderbyDesc = true, string splitChar = "\t", string spaceChar = "\r") { StringBuilder sb = new StringBuilder(); sb.AppendLine(String.Format("[{0}]{1}|{2}|{3}|{4}", "词项", "遗忘词频", "总词频", "词权重", "成熟度")); sb.AppendLine("============================================="); StringBuilder sbkey = new StringBuilder(); HashSet <KeyItemMDL <string> > objBufferSet = new HashSet <KeyItemMDL <string> >(); foreach (string keyword in objKeyWordList) { if (String.IsNullOrWhiteSpace(keyword)) { continue; } if (!objKeyBondColl.Contains(keyword)) { continue; } if (sbkey.Length > 0) { sbkey.Append("、"); } sbkey.Append(keyword); KeyBondMDL <string, string> bond = objKeyBondColl[keyword]; if (objBufferSet.Count <= 0) { objBufferSet.UnionWith(bond.LinkColl); } else { HashSet <KeyItemMDL <string> > buffer = new HashSet <KeyItemMDL <string> >(); foreach (KeyItemMDL <string> mdl in objBufferSet) { if (bond.LinkColl.Contains(mdl.Key)) { buffer.Add(mdl); } } objBufferSet = new HashSet <KeyItemMDL <string> >(buffer); } } KeyItemColl <string> objBufferColl = new KeyItemColl <string>(); foreach (KeyItemMDL <string> mdl in objBufferSet) { if (!objBufferColl.Contains(mdl.Key)) { objBufferColl.Add(mdl); } } sb.AppendLine(); sb.AppendLine(String.Format("【{0}】", sbkey)); sb.Append(KeyItemHelper.ShowKeyItemColl(objBufferColl, nLinkTopCount, false, bIsOrderbyDesc, false, splitChar, spaceChar)); return(sb.ToString()); }
public static string ShowKeyBondColl(KeyBondColl <string, string> objKeyBondColl, List <string> objKeyWordList, int nLinkTopCount, bool bIsOrderbyDesc = true, string splitChar = "\t", string spaceChar = "\r") { StringBuilder sb = new StringBuilder(); sb.AppendLine(String.Format("[{0}]{1}|{2}|{3}|{4}", "词项", "遗忘词频", "总词频", "词权重", "成熟度")); sb.AppendLine("============================================="); foreach (string keyword in objKeyWordList) { if (!objKeyBondColl.Contains(keyword)) { continue; } KeyBondMDL <string, string> bond = objKeyBondColl[keyword]; sb.AppendLine(); sb.AppendLine(String.Format("【{0}】{1}|{2}", bond.KeyItem.Key, Math.Round(bond.KeyItem.ValidCount * KeyBondHelper.CalcRemeberValue <string, string>(bond.KeyItem.Key, objKeyBondColl), 4), Math.Round(bond.KeyItem.TotalCount))); sb.Append(KeyItemHelper.ShowKeyItemColl(bond.LinkColl, nLinkTopCount, false, bIsOrderbyDesc, false, splitChar, spaceChar)); } return(sb.ToString()); }