3 Replies
      Latest reply: Sep 10, 2017 11:37 AM by ManuelMB RSS
      Rufy Level 1 Level 1 (0 points)

        I've tried to use this piece of code taked by Apple Documentation and don't work


        let text = "The ripe taste of cheese improves with age."
        let tagger = NSLinguisticTagger(tagSchemes: [.lexicalClass], options: 0)
        tagger.string = text
        let range = NSRange(location: 0, length: text.utf16.count)
        let options: NSLinguisticTagger.Options = [.omitPunctuation, .omitWhitespace]
        tagger.enumerateTags(in: range, unit: .word, scheme: .tokenType, options: options) { tag, tokenRange, _ in
              if let tag = tag {
                  let word = (text as NSString).substring(with: tokenRange)
                   print("\(word): \(tag)")


        this is the Apple's Doc


        Any solution?