0

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

  • 1
    Please be more specific. What do you mean by "it just gives normal Text and not like the once which I get from Simulator"? Please include the actual outputs both from the Simulator and on a real device. Might be related: [NSLinguisticsTagger enumerateTagsInRange doesn't work on device with NSLinguistic](https://stackoverflow.com/questions/46853473/nslinguistictagger-enumeratetagsinrange-doesnt-work-on-device-with-nslinguistic). What device are you testing on and what device are you simulating? – Dávid Pásztor Dec 12 '17 at 16:20
  • Update your question with actual input and output from both the simulator and the device. – rmaddy Dec 12 '17 at 16:20
  • @DávidPásztor I've edited my question, I'm using an iPhone 7 for both simulating and device testing. – Naveen Saini Dec 12 '17 at 16:29

0 Answers0