Natural language

  • 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.
  • 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
  • Thanks Vincent, that should solve my problems.
    Luca.

    > Subject: Re: Natural language
    > From: <mailinglists...>
    > Date: Sun, 13 Nov 2011 21:37:01 +0100
    > CC: <cocoa-dev...>
    > To: <luca_ciciriello...>
    >
    > 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
  • Just started watching this video - it's awesome.

    - Eric

    On Mon, Nov 14, 2011 at 3:32 AM, Luca Ciciriello <
    <luca_ciciriello...> wrote:

    >
    > Thanks Vincent, that should solve my problems.
    > Luca.
    >
    >> Subject: Re: Natural language
    >> From: <mailinglists...>
    >> Date: Sun, 13 Nov 2011 21:37:01 +0100
    >> CC: <cocoa-dev...>
    >> To: <luca_ciciriello...>
    >>
    >> 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

    >
  • 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 <luca_ciciriello...> wrote:
    >
    > Thanks Vincent, that should solve my problems.
    > Luca.
    >
    >> Subject: Re: Natural language
    >> From: <mailinglists...>
    >> Date: Sun, 13 Nov 2011 21:37:01 +0100
    >> CC: <cocoa-dev...>
    >> To: <luca_ciciriello...>
    >>
    >> 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

    >
  • There is also some documentation available in the Foundation release notes for Lion <> and the NSLinguisticTagger class reference <<A href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSLinguisticTagger_Class/Reference/Reference.html">http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSLin
    guisticTagger_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 <luca_ciciriello...> wrote:
    >>
    >> Thanks Vincent, that should solve my problems.
    >> Luca.
    >>
    >>> Subject: Re: Natural language
    >>> From: <mailinglists...>
    >>> Date: Sun, 13 Nov 2011 21:37:01 +0100
    >>> CC: <cocoa-dev...>
    >>> To: <luca_ciciriello...>
    >>>
    >>> 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

    >>

  • Thanks.
    These references are very useful and Your video (session 128) with Jennifer Moore has been really illuminating.

    Thanks again.

    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 <> and the NSLinguisticTagger class reference <<A href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSLinguisticTagger_Class/Reference/Reference.html">http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSLin
    guisticTagger_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 <luca_ciciriello...> wrote:
    >>>
    >>> Thanks Vincent, that should solve my problems.
    >>> Luca.
    >>>
    >>>> Subject: Re: Natural language
    >>>> From: <mailinglists...>
    >>>> Date: Sun, 13 Nov 2011 21:37:01 +0100
    >>>> CC: <cocoa-dev...>
    >>>> To: <luca_ciciriello...>
    >>>>
    >>>> 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

    >>>


    >
  • 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 <> and the NSLinguisticTagger class reference <<A href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSLinguisticTagger_Class/Reference/Reference.html">http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSLin
    guisticTagger_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 <luca_ciciriello...> wrote:
    >>>
    >>> Thanks Vincent, that should solve my problems.
    >>> Luca.
    >>>
    >>>> Subject: Re: Natural language
    >>>> From: <mailinglists...>
    >>>> Date: Sun, 13 Nov 2011 21:37:01 +0100
    >>>> CC: <cocoa-dev...>
    >>>> To: <luca_ciciriello...>
    >>>>
    >>>> 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

    >>>


    >
  • On Nov 17, 2011, at 7:51 AM, Luca Ciciriello wrote:

    > 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.

    Those are the results you will get if you don't specify the language of the text, and the system concludes that there is insufficient text to confidently identify the language.  If there were additional text in the string you passed in, it would be used to help identify the language.  Alternatively, if you know the language of the text, you can specify it using setOrthography:range:.  That was shown in the final example in the WWDC presentation, in the following form:

        [tagger setOrthography:[NSOrthography orthographyWithDominantScript:@"Latn" languageMap:[NSDictionary dictionaryWithObject:[NSArray arrayWithObject:@"en"] forKey:@"Latn"]] range:NSMakeRange(0, length)];

    which specifies that the text is to be treated as being entirely in English.

    Douglas Davidson
  • Thanks for your answer.
    This solve my problem :-)

    Luca.

    On Nov 17, 2011, at 5:39 PM, Douglas Davidson wrote:

    >
    > On Nov 17, 2011, at 7:51 AM, Luca Ciciriello wrote:
    >
    >> 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.
    >
    > Those are the results you will get if you don't specify the language of the text, and the system concludes that there is insufficient text to confidently identify the language.  If there were additional text in the string you passed in, it would be used to help identify the language.  Alternatively, if you know the language of the text, you can specify it using setOrthography:range:.  That was shown in the final example in the WWDC presentation, in the following form:
    >
    > [tagger setOrthography:[NSOrthography orthographyWithDominantScript:@"Latn" languageMap:[NSDictionary dictionaryWithObject:[NSArray arrayWithObject:@"en"] forKey:@"Latn"]] range:NSMakeRange(0, length)];
    >
    > which specifies that the text is to be treated as being entirely in English.
    >
    > Douglas Davidson
    >
previous month november 2011 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        
Go to today