C# Class CountWordsInString.CountWordsInString

Show file Open project: scottcha/LINQCountWords

Public Methods

Method Description
CountWordsDictionary ( String s1 ) : List

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using dictionary to count the words and LINQ to sort them

CountWordsDictionaryNoLinq ( String s1 ) : List

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using dictionary and sorting using collections.sort

CountWordsLinq ( String s ) : List

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using LINQ

CountWordsLinqForceEvaluate ( String s ) : List

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using LINQ Force evaluation of every LINQ command by using ToList; this is only for performance analysis and should not be used in production code

CountWordsLinqLookup ( String s ) : List

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using LINQ as lookup instead of list

CountWordsLinqLookupForceEvaluate ( String s ) : List

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using LINQ Force evaluation of every LINQ command by using ToList; this is only for performance analysis and should not be used in production code

Private Methods

Method Description
CompareKVPByCount ( int>.KeyValuePair a, int>.KeyValuePair b ) : int

Delegate method to compare KeyValuePairs for sorting

ExtractTopTen ( IEnumerable countedWordsEnum ) : List

Returns the top 10 values from an IEnumerable or a subset if there are fewer than 10 values

ExtractTopTen ( int>.List countedWords ) : List

Returns the top 10 values from a list of KeyValuePairs or subset if there are fewer than 10 values

ExtractTopTen ( List countedWords ) : List

Returns the top 10 values from a list or a subset if there are fewer than 10 values

StringToWordDictionary ( string s1 ) : int>.Dictionary

Creates a dictionary of words for a string with key being the word and value the # of times the word occurs in the string

Method Details

CountWordsDictionary() public static method

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using dictionary to count the words and LINQ to sort them
public static CountWordsDictionary ( String s1 ) : List
s1 String string to parse
return List

CountWordsDictionaryNoLinq() public static method

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using dictionary and sorting using collections.sort
public static CountWordsDictionaryNoLinq ( String s1 ) : List
s1 String string to parse
return List

CountWordsLinq() public static method

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using LINQ
public static CountWordsLinq ( String s ) : List
s String string to parse
return List

CountWordsLinqForceEvaluate() public static method

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using LINQ Force evaluation of every LINQ command by using ToList; this is only for performance analysis and should not be used in production code
public static CountWordsLinqForceEvaluate ( String s ) : List
s String string to parse
return List

CountWordsLinqLookup() public static method

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using LINQ as lookup instead of list
public static CountWordsLinqLookup ( String s ) : List
s String string to parse
return List

CountWordsLinqLookupForceEvaluate() public static method

Returns top 10 most frequently occuring words (naive definition of word) which occur in a string using LINQ Force evaluation of every LINQ command by using ToList; this is only for performance analysis and should not be used in production code
public static CountWordsLinqLookupForceEvaluate ( String s ) : List
s String string to parse
return List