我在 C# 中下载了一个云控件,它使用IEnumerable来计数、排序和过滤我想创建一个方法来帮助我添加IWord(字符串文本,int 出现)
其他方法是
public static IEnumerable<IWord> CountOccurences(this IEnumerable<string> terms)
{
return
terms.GroupBy(
term => term,
(term, equivalentTerms) => new Word(term, equivalentTerms.Count()),
StringComparer.InvariantCultureIgnoreCase)
.Cast<IWord>();
}
public static IEnumerable<string> Filter(this IEnumerable<string> terms, IBlacklist blacklist)
{
return
terms.Where(
term => !blacklist.Countains(term));
}