6

Does anyone understand why this is happening?

On any simulator all of the schemes are found with the following code:

NSArray<NSLinguisticTagScheme> *availSchemes = [NSLinguisticTagger availableTagSchemesForLanguage:@"en"];
for (NSLinguisticTagScheme scheme in availSchemes) {
    NSLog(@"Tag scheme %@", scheme);
}

yielding the following:

2018-02-13 09:12:54.066970-0500 MY_APP[79671:5737063] Tag scheme Language
2018-02-13 09:12:54.067160-0500 MY_APP[79671:5737063] Tag scheme Script
2018-02-13 09:12:54.067300-0500 MY_APP[79671:5737063] Tag scheme TokenType
2018-02-13 09:12:54.067425-0500 MY_APP[79671:5737063] Tag scheme LexicalClass
2018-02-13 09:12:54.067541-0500 MY_APP[79671:5737063] Tag scheme NameType
2018-02-13 09:12:54.067655-0500 MY_APP[79671:5737063] Tag scheme NameTypeOrLexicalClass
2018-02-13 09:12:54.067768-0500 MY_APP[79671:5737063] Tag scheme Lemma

However, on my device (iPhone 6s iOS 11.2) I receive the following..

2018-02-13 09:13:09.834879-0500 MY_APP[4327:313598] Tag scheme Language
2018-02-13 09:13:09.835256-0500 MY_APP[4327:313598] Tag scheme Script
2018-02-13 09:13:09.835556-0500 MY_APP[4327:313598] Tag scheme TokenType

Can anyone help explain to me why I cannot access the other schemes? In particular I am looking to be able to use the NSLinguisticTagSchemeLexicalClass with NSLinguisticTagger. Currently this issue is causing the tagger to tag any word as (OtherWord), instead of it's true part of speech.

Any help would be appreciated..

UPDATE

ALL physical devices give me the same results - only three available schemes... I am at a loss here.

Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
  • There are all schemes available on iPhone X, so some devices can access them all.. IMO not all schemes are available on all devices. Simulator can access them, because these schemes are available on your computer. – kiwisip Feb 18 '18 at 20:11
  • That seems to be the case yes... I understand *what* is happening - I am still searching for an actual explanation as to why this is / what can be done about it. I have a hard time believing such a discrepancy would exist across their device lineup – Will Von Ullrich Feb 18 '18 at 20:30

2 Answers2

6

After tireless research, sleepless nights, and three trips to the ward, I found out the problem. While the fix was by all means the poor man's solution, it worked nonetheless.


For whatever reason my iPhone 6s iOS 11.2.5 didn't feel like installing all of the available linguistic schemes when I originally set up my phone? Either that or it decided to remove them one day when it was bored.

Regardless, the solution was... drum roll...

Uninstall the target language...then reinstall it.


I guess this "reset" the language package to re-include these schemes. Happy codinggg

Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
2

The WWDC presentation covering this topic shows that far from all languages are supported for all schemes. In fact, several schemes are only supported for the following languages:

  • English
  • French
  • Italian
  • German
  • Portuguese
  • Russian
  • Turkish

If you download the slides on the linked page below you can see a table of this on slide 136.

When I run your code on my devices they all report the full set that you got on the simulator for en. With other language codes I get less. Did you check your iOS versions on your devices vs simulator?

WWDC 2017:208 - Natural Language Processing and your Apps

LGP
  • 4,135
  • 1
  • 22
  • 34
  • I am testing in english on my 6s iOS 11.2 and it only shows me the three schemes. On the simulator it shows all the schemes for any iOS on any device (of course since my mac has all the schemes). Why would some devices not have them?? I don't understand what I can do to fix this... – Will Von Ullrich Feb 19 '18 at 13:24
  • Hmm, I see them on all my devices. Did you try switching language on your device? Or do you already have it in English? – LGP Feb 19 '18 at 13:26
  • By the way, I did my tests on an iPhone 6S also. Which leads me to think it might have something to do with the configuration. But I have 11.2.5 installed. – LGP Feb 19 '18 at 13:28
  • haha I already have it in English.. I can't imagine it being anything to do with my build so it must be a device problem.. but how I have tried this on a 5c iOS 10.3 as well and the same results... ALSO others have had the same issue - https://stackoverflow.com/questions/46853473/nslinguistictagger-enumeratetagsinrange-doesnt-work-on-device-with-nslinguistic – Will Von Ullrich Feb 19 '18 at 13:31
  • My last thought - is this because I am attempting to access this via an extension?... I am trying to use this in a keyboard extension to be able to determine the part of speech of the last word the user entered – Will Von Ullrich Feb 19 '18 at 13:37
  • So the actual problem was that you did the call from a keyboard extension? – LGP Feb 19 '18 at 13:42
  • Check my answer. I thought maybe that was the issue.. but no. Somehow my phone felt I "didn't need" all the schemes and got rid of them one day. I uninstalled English then added it again and now it works *even* in the extension as it should – Will Von Ullrich Feb 19 '18 at 13:48