简体   繁体   English

我们如何在iOS中制作自定义NSLinguisticTagger tagSchemes?

[英]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. 我正在使用NSLinguisticTagger类来过滤或查找使用行字符串的地名,名称,组织名称,电话号码,手机号码,地址(如家庭住址,办公地址等)。

There are 3 option like 1. NSLinguisticTagPlaceName 2. NSLinguisticTagOrganizationName 3. NSLinguisticTagPersonalName 有3个选项,例如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. 如果是,那么我们如何在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.). NSLinguisticTagger用于分解单词并将其分类为更基本的句子片段(动词,名词,形容词,名称等)。 To find phone numbers, addresses, dates, etc. try looking at NSDataDetector 要查找电话号码,地址,日期等,请尝试查看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)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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