A simple example.
let tagger = NSLinguisticTagger(tagSchemes: [.lexicalClass], options: 0) tagger.string = "This is the sample sentence." var score: NSArray? = nil let result = tagger.possibleTags(at: 10, scheme: NSLinguisticTagScheme.lexicalClass.rawValue, tokenRange: nil, sentenceRange: nil, scores: &score) print(result, score)
Thank you. The code works.
The main difference I see from what I was trying is the tagSchemes on tagger creation. I was using NSLinguisticTagger.availableTagSchemes(forLanguage: "en"), which worked great when I am using the enumerateTags function, but seems to be a problem when using possibleTags.
enumerateTags is great at tokenization, but is fairly poor in tagging parts-of-speech in a sentence correctly, so I was looking to get the possible tags for each word to incorporate an older parser algorithm I created 10 years ago to parse the sentences using hints from enumerateTags to speed things up.