I'm making a simple linguistic tagger app in which it takes user input and gives the tags and token. It works fine in the simulator but when I run it in my device, it doesn't do the same.
This is the code I've used:
@IBAction func callML(_ sender: Any) {
let entryString = self.entryField.text!
print(entryString)
self.view .endEditing(true)
let schemes = NSLinguisticTagger.availableTagSchemes(forLanguage: "en-IN")
let options: NSLinguisticTagger.Options = [
.omitWhitespace, .omitPunctuation, .joinNames
]
let tagger = NSLinguisticTagger(tagSchemes: schemes, options: Int(options.rawValue))
tagger.string = entryString
let rangeOfEntireEntryString = NSRange(location: 0, length: entryString.utf16.count)
tagger.enumerateTags(
in: rangeOfEntireEntryString,
scheme: .nameTypeOrLexicalClass,
options: options)
{ (tag, tokenRange, sentenceRange, _) in
guard let tag = tag?.rawValue else { return }
let token = (entryString as NSString).substring(with:
tokenRange)
print("[\(tag)] \(token)")
if tag.count==12{
print("This is for personal name")
print(token)
name=token
}
}
}
When I print the tags and tokens in the console it just gives normal text and not like the one which I get from the simulator.
Input in text Field: Meet the Man
Output in console when using Simulator:
[Verb] meet
[Determiner] the
[Noun] man
Output in console when using Device: Meet the Man