Objective C Enumerate Sentences in a paragraph
        Posted  
        
            by 
                Faz Ya
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Faz Ya
        
        
        
        Published on 2012-06-27T18:30:29Z
        Indexed on 
            2012/06/30
            15:17 UTC
        
        
        Read the original article
        Hit count: 352
        
I would like to write an enumerator that would go through a paragraph of text and gives me one sentence at a time. I tried using stringEnumerate with the NSStringEnumerationBySentences but that simply looks at the periods and fails. For example, lets say I have the following text Block:
"Senator John A. Boehner decided not to move forward. He also decided not to call the congress. The news reporter said though...."
I would like my function to break down the above paragraph in the following sentences:
Senator John A. Boehner decided not to move forward
He also decided not to call the congress (No third sentence because it's a half a sentence)
The String Enumerator with the sentence optionjust looks at the periods and breaks down that way which is wrong:
Senator John A.
Boehner decided not to move forward
He also decided not to call the congress
The news reporter said though....
Is there any library or function that I can call that does a better job at this?
Thanks
- (NSMutableString *) getOnlyFullSentencesFromTextBlock:(NSMutableString *) textBlock{
    [textBlock enumerateSubstringsInRange:NSMakeRange(0, [textBlock length])
                                  options:NSStringEnumerationBySentences | NSStringEnumerationLocalized
                                usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop)
    {
        NSLog(@"Sentence Frag:%@", substring);                                                                        
    }];
    return textBlock;
}
        © Stack Overflow or respective owner