Word frequency: Difference between revisions
Content added Content deleted
Line 2,369: | Line 2,369: | ||
CFDictionaryRef dict |
CFDictionaryRef dict |
||
// |
// Depending on the value of the caseSensitive Boolean function parameter above, lowercase incoming text |
||
if caseSensitive == NO then textStr = fn StringLowercaseString( textStr ) |
if caseSensitive == NO then textStr = fn StringLowercaseString( textStr ) |
||
// Trim non-alphabetic characters from string and separate individual words with a space |
// Trim non-alphabetic characters from string, and separate individual words with a space |
||
CFStringRef tempStr = fn ArrayComponentsJoinedByString( fn StringComponentsSeparatedByCharactersInSet( textStr, fn CharacterSetInvertedSet( fn CharacterSetLetterSet ) ), @" " ) |
CFStringRef tempStr = fn ArrayComponentsJoinedByString( fn StringComponentsSeparatedByCharactersInSet( textStr, fn CharacterSetInvertedSet( fn CharacterSetLetterSet ) ), @" " ) |
||
Line 2,390: | Line 2,390: | ||
CountedSetRef freqencies = fn CountedSetWithArray( tempArr ) |
CountedSetRef freqencies = fn CountedSetWithArray( tempArr ) |
||
// Enumerate each word- |
// Enumerate each word-frequency pair in the counted set... |
||
EnumeratorRef enumRef = fn CountedSetObjectEnumerator( freqencies ) |
EnumeratorRef enumRef = fn CountedSetObjectEnumerator( freqencies ) |
||
Line 2,429: | Line 2,429: | ||
next |
next |
||
// Create output string from mutable |
// Create an immutable output string from mutable the string |
||
CFStringRef resultStr = fn StringWithFormat( @"%@", mutStr ) |
CFStringRef resultStr = fn StringWithFormat( @"%@", mutStr ) |
||
end fn = resultStr |
end fn = resultStr |
||
Line 2,459: | Line 2,459: | ||
HandleEvents |
HandleEvents |
||
</lang> |
</lang> |
||
{{ |
{{output}} |
||
<pre> |
<pre> |
||
1 41095 the |
1 41095 the |