• 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
Re: Natural language
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Natural language


  • Subject: Re: Natural language
  • From: Luca Ciciriello <email@hidden>
  • Date: Thu, 17 Nov 2011 16:51:30 +0100

Hi, All.
I've implemented some sample code using NSLinguisticTagger class and i've found some weird behavior.
I'me using the following code to analyze a simple english phrase:

NSRange textrange = NSMakeRange(0, [phrase length]);
    [tagger enumerateTagsInRange:textrange
                          scheme:NSLinguisticTagSchemeLexicalClass
                         options:0
                         usingBlock:
                                    ^(NSString *wordType,
                                      NSRange wordRange,
                                      NSRange sentenceRange, BOOL *stop)
                                      {
                                        if(wordType == NSLinguisticTagNoun)
                                        {
                                           // Show tag
                                        }
					if(wordType == NSLinguisticTagPronoun)
                                        {
                                           // Show tag
                                        }
					if(wordType == NSLinguisticTagDeterminer)
                                        {
                                           // Show tag
                                        }

					…etc for each NSLinguisticSomething constant.

                                      }];

If I analyze the phrase: "I am a woman" I got the correct result :

I --> pronoun
am --> verb
A --> determiner
woman --> noun

but if i analyze the phrase: "I am a man" I got the result:

I --> otherword
am --> otherword
a --> otherword
man --> otherword.

I've initialized the NSLinguisticTagger class as follow:

NSArray *tagScheme = [NSArray arrayWithObjects:NSLinguisticTagSchemeLexicalClass,
                                                       NSLinguisticTagSchemeNameType,
                                                       NSLinguisticTagSchemeLanguage, nil];
        tagger = [[NSLinguisticTagger alloc] initWithTagSchemes:tagScheme options:0];


So where is my mistake? Why I get an error if I try to analyze a simple phrase like "I am a man"?
The behavior is the same on the device (iOS 5.0.1) and on the simulator. I'm using MaOS X 10.7.2 with Xcode 4.2.

Thanks for any answer.

Luca.

On Nov 14, 2011, at 5:56 PM, Douglas Davidson wrote:

> There is also some documentation available in the Foundation release notes for Lion <http://developer.apple.com/library/mac/#releasenotes/Cocoa/Foundation.html> and the NSLinguisticTagger class reference <http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSLinguisticTagger_Class/Reference/Reference.html>.  If you have specific questions, you can send them to the list.
>
> Douglas Davidson
>
> On Nov 14, 2011, at 7:02 AM, Luca Ciciriello wrote:
>
>> Yes, indeed!!!
>>
>> On Nov 14, 2011, at 2:56 PM, Eric E. Dolecki wrote:
>>
>>> Just started watching this video - it's awesome.
>>>
>>> - Eric
>>>
>>> On Mon, Nov 14, 2011 at 3:32 AM, Luca Ciciriello <email@hidden> wrote:
>>>
>>> Thanks Vincent, that should solve my problems.
>>> Luca.
>>>
>>>> Subject: Re: Natural language
>>>> From: email@hidden
>>>> Date: Sun, 13 Nov 2011 21:37:01 +0100
>>>> CC: email@hidden
>>>> To: email@hidden
>>>>
>>>> The "Advanced Text Processing" session from WWDC '11 should be of help.
>>>> https://developer.apple.com/videos/wwdc/2011/
>>>>
>>>> On Nov 13, 2011, at 4:31 PM, Luca Ciciriello wrote:
>>>>
>>>>> Hi All.
>>>>> Any one knows how to use the class NSLinguisticTagger in order to decompose a phrase in its grammar components (name, adjective, verb, etc.)?
>>>>>
>>>>> Thanks for any answer.
>>>>>
>>>>> Luca
>>>                                        _______________________________________________
>>>
>>> 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
>>>
>>
>> _______________________________________________
>>
>> 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
>
> _______________________________________________
>
> 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
>

_______________________________________________

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: Natural language
      • From: Douglas Davidson <email@hidden>
References: 
 >Natural language (From: Luca Ciciriello <email@hidden>)
 >Re: Natural language (From: Vincent <email@hidden>)
 >RE: Natural language (From: Luca Ciciriello <email@hidden>)
 >Re: Natural language (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Natural language (From: Luca Ciciriello <email@hidden>)
 >Re: Natural language (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Resizable borderless windows in Lion
  • Next by Date: Re: Natural language
  • Previous by thread: Re: Natural language
  • Next by thread: Re: Natural language
  • Index(es):
    • Date
    • Thread