Code: Select all
import NaturalLanguage
struct Scorer {
let tagger = NLTagger(tagSchemes: [.sentimentScore])
func score(_ text: String) -> Double {
var sentimentScore: Double = 0
tagger.string = text
tagger.enumerateTags(in: text.startIndex..Code: Select all
import NaturalLanguage
struct Scorer {
let tagger = NLTagger(tagSchemes: [.sentimentScore])
func score(_ text: String) -> Double {
var sentimentScore: Double = 0
tagger.string = text
tagger.enumerateTags(in: text.startIndex..