简体   繁体   中英

How we can make the custom NSLinguisticTagger tagSchemes in iOS?

I am working NSLinguisticTagger class to filter or find the Place name, Name, Organisation name, Phone number, Mobile number, Address like Home address, office address etc, using a row string.

There are 3 option like 1. NSLinguisticTagPlaceName 2. NSLinguisticTagOrganizationName 3. NSLinguisticTagPersonalName

There are no other option for mobile number, Telephone number, fax number etc,

So My question is, can we make own custom tag scheme class. If YES then how we can implement that class in iOS.

The result of already given option is not good. How I can improve its result.

Thanks.

NSLinguisticTagger is used to break apart words and classify them into more basic sentence pieces (verbs, nouns, adjectives, names, etc.). To find phone numbers, addresses, dates, etc. try looking at NSDataDetector

let message = "What did I do on October 4"
let types: NSTextCheckingResult.CheckingType = [NSTextCheckingResult.CheckingType.date]
let detector = try? NSDataDetector(types: types.rawValue)
    detector?.enumerateMatches(in: message, options: [], range: NSMakeRange(0, (message as NSString).length)) { (result, flags, _) in
    print(result)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM