我的代码在操场上工作,Xcode 没有显示任何错误,但是当我在命令行上编译文件时,它会返回错误
use of undeclared type NSLinguisticTagScheme
and String has no member 'tokenType'
这是问题代码。
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)
})
有任何想法吗?