Device vs. Simulator Linguistic Schemes
Asked Answered
C

2

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.

Creole answered 13/2, 2018 at 14:18 Comment(2)
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.Prefrontal
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 lineupCreole
C
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

Creole answered 19/2, 2018 at 13:47 Comment(3)
What the hell is this, Apple?Guiana
Could you please tell me, how exactly did you uninstall the target lang ? PS: i am facing the same issue with NSLinguisticTagScheme on all devices.Seemaseeming
Uninstall the language in settings on the device (in my case it was English haha)Creole
E
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

Emyle answered 19/2, 2018 at 9:59 Comment(7)
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...Creole
Hmm, I see them on all my devices. Did you try switching language on your device? Or do you already have it in English?Emyle
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.Emyle
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 - #46853973Creole
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 enteredCreole
So the actual problem was that you did the call from a keyboard extension?Emyle
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 shouldCreole

© 2022 - 2024 — McMap. All rights reserved.