使用未声明的类型NSLinguisticTagScheme

时间:2017-10-19 22:23:58

标签: swift4 macos-high-sierra nslinguistictagger

我在操场上有代码,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)
})

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

更新Xcode解决了这个问题