0

C# でクラウド コントロールをダウンロードしました。IEnumerableを使用して countOccurence、Sort、およびフィルター処理を行います。IWord(string text,int occurence)を追加するのに役立つメソッドを作成したかったのです。

他の方法は

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));



    }
4

1 に答える 1

0
public static IEnumerable<IWord> AddOwnItems(this IEnumerable<string> terms)
    {
        IEnumerable<IWord> obj = new List<IWord>()
        {
          new Word("Development", 12), new Word("Extractor", 24), new Word("Anyother", 18)
        ,new Word("wao", 12),new Word("yours", 18),new Word("how does", 28),new Word("coudnt", 20),new Word("adkj", 22),
        new Word("own", 12),new Word("items", 10),new Word("terms ", 14),new Word("whats", 12),new Word("uupp", 16),
        new Word("Zar E Ahmer", 36),new Word("Cool", 26),new Word("Yhoo", 18),new Word("I am", 14),new Word("never", 16),
        new Word("thirty May", 12),new Word("string", 10),new Word("nothing", 14),new Word("much", 12),new Word("Disney", 16)
        };
        return obj;

    }

問題が解決するよりもこのコードを使用します

于 2013-06-24T09:28:48.643 に答える