Re: Natural language
Re: Natural language
- Subject: Re: Natural language
- From: Douglas Davidson <email@hidden>
- Date: Thu, 17 Nov 2011 08:39:43 -0800
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
_______________________________________________
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