Word frequency: Difference between revisions

Content added Content deleted
Line 2,377: Line 2,377:
// Prepare separators to parse string into array
// Prepare separators to parse string into array
CFMutableCharacterSetRef separators = fn MutableCharacterSetInit
CFMutableCharacterSetRef separators = fn MutableCharacterSetInit
MutableCharacterSetFormUnionWithCharacterSet( separators, fn CharacterSetPuntuationSet ) // Informally, this set is the set of all non-whitespace characters used to separate linguistic units in scripts, such as periods, dashes, parentheses, and so on.
MutableCharacterSetFormUnionWithCharacterSet( separators, fn CharacterSetWhitespaceAndNewlineSet ) // A character set containing all the whitespace and newline characters. A character set containing characters in Unicode General Category Z*, U+000A ~ U+000D, and U+0085.


// Informally, this set is the set of all non-whitespace characters used to separate linguistic units in scripts, such as periods, dashes, parentheses, and so on.
// Create array of separated words
MutableCharacterSetFormUnionWithCharacterSet( separators, fn CharacterSetPuntuationSet )

// A character set containing all the whitespace and newline characters including characters in Unicode General Category Z*, U+000A U+000D, and U+0085.
MutableCharacterSetFormUnionWithCharacterSet( separators, fn CharacterSetWhitespaceAndNewlineSet ) // Create array of separated words
CFArrayRef tempArr = fn StringComponentsSeparatedByCharactersInSet( tempStr, separators )
CFArrayRef tempArr = fn StringComponentsSeparatedByCharactersInSet( tempStr, separators )


Line 2,443: Line 2,445:
NSLogClear
NSLogClear
NSLog( @"%@", frequencyStr )
NSLog( @"%@", frequencyStr )
NSLog( @"Total words in document: %@", fn AppProperty( @"totalWords" ) )
NSLog( @"Total unique words in document: %@", fn AppProperty( @"totalWords" ) )
// Stop timer and log elapsed processing time
// Stop timer and log elapsed processing time
NSLog( @"Elapsed time: %f milliseconds.", ( fn CFAbsoluteTimeGetCurrent - startTime ) * 1000.0 )
NSLog( @"Elapsed time: %f milliseconds.", ( fn CFAbsoluteTimeGetCurrent - startTime ) * 1000.0 )