I have the code working in a playground, and Xcode shows no bugs, but when I compile the file on the command line it comes back with the errors
use of undeclared type NSLinguisticTagScheme
and String has no member 'tokenType'
Heres the problem code.
let tagSchemes : [NSLinguisticTagScheme] = [ .tokenType]
let tagger : NSLinguisticTagger = NSLinguisticTagger(tagSchemes: tagSchemes, options: 0)
let options : NSLinguisticTagger.Options = [ .omitPunctuation, .omitWhitespace]
tagger.string = text
let range = NSRange(location: 0, length: text.utf16.count)
tagger.enumerateTags( in: range, unit: .sentence, scheme: .tokenType, options: options, using:
{ tag, tokenRange, stop in
let token = (text as NSString).substring(with: tokenRange)
sentences.append(token)
})
Any ideas?
更新Xcode解决了该问题
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.