• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Abstract Text Example and Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Abstract Text Example and Question


  • Subject: Abstract Text Example and Question
  • From: Brad Stone <email@hidden>
  • Date: Wed, 9 Feb 2011 22:04:58 -0500

I made this code to remove any duplicate words from a large group of text.  The result is stored in an index file so the text doesn't need to make sense.  I'm removing the duplicates to save space in the index file.  I was wondering if anyone had a suggestion for a more efficient way to accomplishing this.  I'm guessing the separations and joins are taking up memory and slowing things down (even though I'm not positive about that).  Using this code reduced the index file size form 4.7MB to 2.7MB.

Thanks

- (NSString *)abstractText:(NSString *)srcString {
	NSMutableArray *resultArray = [[NSMutableArray alloc] init];
	NSArray *textArray = [srcString componentsSeparatedByString:@" "];
	for (NSString *s in textArray) {

		s = [s stringByTrimmingCharactersInSet:[NSCharacterSet alphanumericCharacterSet]];
		s = [s lowercaseString];

		if ([resultArray indexOfObject:s] == NSNotFound) {
			[resultArray addObject:s];
		}
	}

	NSString *resultString = nil;
	if ([resultArray count] > 0) {
		resultString = [resultArray componentsJoinedByString:@" "];
	} else {
		resultString = srcString;
	}
	return resultString;
}_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Abstract Text Example and Question
      • From: Graham Cox <email@hidden>
  • Prev by Date: NSOutlineView + NSButtonCell weird bug
  • Next by Date: Re: Abstract Text Example and Question
  • Previous by thread: Re: NSOutlineView + NSButtonCell weird bug
  • Next by thread: Re: Abstract Text Example and Question
  • Index(es):
    • Date
    • Thread