Lemmatizing textual content works on bodily gadgets, however not Xcode previews, simulators, or checks. This code works on bodily gadgets (Mac, iOS 16.4, iOS 17.3) however not on Xcode previews, simulators, or Xcode checks.
import SwiftUI
import NaturalLanguage
struct ContentView: View {
var physique: some View {
VStack {
Textual content(lemmatize())
}
}
func lemmatize() -> String {
let textual content = "Pumpkins develop gradual. Automobiles are quick."
let tagger = NLTagger(tagSchemes: [.lemma])
tagger.string = textual content
print (tagger.tagSchemes)
var lemmaText: String = ""
tagger.enumerateTags(in: textual content.startIndex..<textual content.endIndex, unit: .phrase, scheme: .lemma) { tag, vary in
let stemForm = tag?.rawValue ?? String(textual content[range])
lemmaText += stemForm
return true
}
return lemmaText
}
}
Given the string “Pumpkins develop gradual. Automobiles are quick.”, I anticipate -> “pumpkin develop gradual. automotive be quick.”. Nevertheless, I get the string again unmodified on the simulators (a number of iOS variations). Working on newest Xcode and Sonoma.