Simplistically: 

Parse words of text into an array of words.(Or an array of NSRanges)

Test each word for "numberness" (non-nil return) using NSNumberFormatter. 
Group sequential numeric words (like "seventy three") into strings and evaluate 
with NSNumberFormatter to get numeric value. 

There will be edge cases and ambiguities. Is "seventy, three" {70,3} or 73?

Only the specifics of your app can decide.  

Cocoa offers several tools that can parse text into words with varying degrees 
of sophistication. 

Kirk Kerekes 
(iPhone)

On Mar 28, 2013, at 7:44 AM, "Eric E. Dolecki" <edole...@gmail.com> wrote:

> How would you go about looking for arbitrary numeric word(s) in a string to 
> then convert using the NSNumberFormatterSpellOutStyle? Using NLP in Obj-C? 
> 
> 
> 
>   Google Voice: (508) 656-0622
>   Twitter: eric_dolecki      XBoxLive: edolecki      PSN: eric_dolecki
>   Imagineric
> 
> 
> On Wed, Mar 27, 2013 at 5:02 PM, Kirk <kirkkere...@gmail.com> wrote:
>> On Mar 27, 2013, at 3:51 PM, "Eric E. Dolecki" <edole...@gmail.com> wrote:
>> 
>>> !!!!!
>> 
>> Yeah, that was my reaction also. 
>> 
>> When you do try text it can't interpret ("eleventy-seven", "dozen"), nil is 
>> returned. 
>> 
>> It would seem like one could thus do a fairly easy scheme of locating 
>> numeric words in arbitrary text, then grouping consecutive numeric words, 
>> then resubmitting the groups for conversion to numeric values. 
>> 
>> Combine with spellcheck, and stir. 
>> 
>>> 
>>> Thank you :)
>>> 
>>> 
>>> 
>>>   Google Voice: (508) 656-0622
>>>   Twitter: eric_dolecki      XBoxLive: edolecki      PSN: eric_dolecki
>>>   Imagineric
>>> 
>>> 
>>> On Wed, Mar 27, 2013 at 3:51 PM, Kirk <kirkkere...@gmail.com> wrote:
>>>>    NSNumberFormatter * nf = [[NSNumberFormatter new] autorelease];
>>>>    [nf setNumberStyle: NSNumberFormatterSpellOutStyle];
>>>>    NSLog(@"Survey Says...%@", [nf numberFromString:@"three"]);
>>>> 
>>>> Yields "Survey Says...3"
>>>> 
>>>> ** Also worked with "seventy-three" and "thirteen point five" **
>>>> 
>>>> This was under iOS.
>>>> 
>>>> Personally, I was gobsmacked at the results.
>>>> 
>>>> Kirk Kerekes
>>>> (iPhone)
> 
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to