Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7844045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:45:24+00:00 2026-06-02T16:45:24+00:00

I got a UITextView with an arbitrary length text (up to 10000 characters). I

  • 0

I got a UITextView with an arbitrary length text (up to 10000 characters). I need to parse this text, extract all keywords and list them by the frequency of use with the most frequently used word being on top, next one down, etc. I will most likely present a modal UITableView after the operation is completed.

I’m thinking of an efficient and useful way to do this. I can try to separate a string using a delimiter in the form of [whitespace, punctuation marks, etc].
This gets me an array of character sequences.
I can add each add sequence as an NSMutableDictionary key, and increment its count once I see another instance of that word. However, this may result in a list of 300-400 words, most having frequency of 1.

Is there a good way to implement the logic that I’m describing? Should I try to sort the array in alphabetical order and try some kind of “fuzzy” logic match? Are there any NSDataDetector or NSString methods that can do this kind of work for me?

An additional question is: how would I extract stuff like a, at, to, for, etc, and do not list them in my keyword list?

It would be great if I can take a look at a sample project that has already accomplished this task.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:45:27+00:00Added an answer on June 2, 2026 at 4:45 pm

    I ended up going with the CFStringTokenizer . I’m not sure if the bridged casts below are correct, but it seems to work

    -(void)listAllKeywordsInString:(NSString*)text
        {
            if(text!=nil)
            {
                NSMutableDictionary* keywordsDictionary = [[NSMutableDictionary alloc] initWithCapacity:1024];
                NSString* key = nil;
                NSLog(@"%@",text);
    
                 NSLog(@"Started parsing: %@",[[NSDate date] description]);
    
                CFStringRef string =(__bridge CFStringRef)text; // Get string from somewhere
    
            CFStringTokenizerRef tokenizer = CFStringTokenizerCreate(kCFAllocatorDefault,  (__bridge_retained CFStringRef) text, CFRangeMake (0,CFStringGetLength((__bridge_retained CFStringRef)text)), kCFStringTokenizerUnitWord, CFLocaleCopyCurrent());
    
                unsigned tokensFound = 0; // or the desired number of tokens
    
                CFStringTokenizerTokenType tokenType = kCFStringTokenizerTokenNone;
    
                while(kCFStringTokenizerTokenNone != (tokenType = CFStringTokenizerAdvanceToNextToken(tokenizer)) ) {
                    CFRange tokenRange = CFStringTokenizerGetCurrentTokenRange(tokenizer);
                    CFStringRef tokenValue = CFStringCreateWithSubstring(kCFAllocatorDefault, string, tokenRange);
    
                    // This is the found word
                    key =(__bridge NSString*)tokenValue;
    
                    //increment its count
                    NSNumber* count = [keywordsDictionary objectForKey:key];
                    if(count!=nil)
                    {
                         [keywordsDictionary setValue:[NSNumber numberWithInt:1] forKey:key];
                    }else {
                        [keywordsDictionary setValue:[NSNumber numberWithInt:count.intValue+1] forKey:key];
                    }
    
    
    
                    CFRelease(tokenValue);
    
                    ++tokensFound;
                }
                NSLog(@"Ended parsing. tokens Found: %d, %@",tokensFound,[[NSDate date] description]);
                NSLog(@"%@",[keywordsDictionary description]);
                // Clean up
                CFRelease(tokenizer);
    
            }
    
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got a requirement to rebuild mssql full-text index. Problem is - I need to
getting text from a .rtf file : this is what i've got so far...
I've got a UITextView inside a UIScrollView (specifically, the text view is in a
I've got my UITextView set up for scrolling like this, -(void)startAutoScroll { NSLog(@AutoScroll Started);
Say you've got a UITextView populated with a chunk of text. When a user
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
Got a strange problem created a little stored proc which need to execute a
Got a c#.net app which I need to modify. The query at the moment
I've got a bit of a doubt with UITextView s. I use to put
I've got a CCScene with few UIKit elements [UITextView for example]. After some user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.