NLTagger does not enumerate anymore?

I am using NLTagger to tag lexical classes of words, but it suddenly just stopped working. I boiled my code down to the most basic version, but it's never executing the closure of the enumerateTags() function. What do I have to change or what should I try?

    for e in sentenceArray {
    
    let cupcake = "I like you, have a cupcake"
    tagger.string = cupcake
    tagger.enumerateTags(in: cupcake.startIndex..<cupcake.endIndex, unit: .word, scheme: .nameTypeOrLexicalClass) { tag, range in
        print("TAG")
        return true
    }
Answered by yoKurt in 695041022

Solution: after changing .nameTypeOrLexicalClass to just .lexicalClass, it executed the closure.

Accepted Answer

Solution: after changing .nameTypeOrLexicalClass to just .lexicalClass, it executed the closure.

NLTagger's enumerateTags() API remains broken. Even after following Apple's example from the developer documentation, which is meant to demonstrate how to identify parts of speech in a given text, the only tag returned for each word is OtherWord (see attached screenshot).

I got OtherWord on iOS 17 simulator, iOS 16 simulator works well.

NLTagger's enumerateTags() and tags() methods are both broken. I've submitted a bug report. What I find weird is that nobody has reported any similar issues so far.

I have the same issue in iOS (Mac is working). Also, requestAssets does not seem to load either.

NLTagger does not enumerate anymore?
 
 
Q