简体   繁体   English

如何为NSLinguisticTagger添加名称?

[英]How to add names to NSLinguisticTagger?

I'm currently doing work with people using speech recognition and detecting names in speech. 我目前正在与使用语音识别和在语音中检测姓名的人一起工作。 This works well however I'm having issues with names. 这很好用,但是我遇到名字问题。 I'm in Wales and many people around have Welsh names (including me). 我在威尔士,很多人都有威尔士人的名字(包括我)。 I have a CSV of all the Welsh Names. 我有一张所有威尔士名字的CSV。 Some names are also being picked up as Places (like Osian) Is there a way to extend the NSLinguisticTagger to include Welsh Names? 有些名字也被收录为地方(如Osian)有没有办法扩展NSLinguisticTagger以包含威尔士名字? Or is there a way of detecting the Welsh name? 或者有没有办法检测威尔士名字?

Here is my current code: 这是我目前的代码:

let text = "Hey I'm Osian"

// 2
let tagger = NLTagger(tagSchemes: [.nameType])
tagger.string = text

let options: NLTagger.Options = [.omitPunctuation, .omitWhitespace, .joinNames]
let tags: [NLTag] = [.personalName, .organizationName, .placeName]

// 3
tagger.enumerateTags(in: text.startIndex..<text.endIndex, unit: .word, scheme: .nameType, options: options) { tag, tokenRange in
    if let tag = tag, tags.contains(tag) {
        print("\(text[tokenRange]): \(tag.rawValue)")
    }
    return true
}

Normally you need to set the dominant language. 通常你需要设置主导语言。 But it appears that Welsh is not supported. 但似乎不支持威尔士语。 See: https://developer.apple.com/documentation/naturallanguage/nllanguage?language=objc 请参阅: https//developer.apple.com/documentation/naturallanguage/nllanguage?language = objc

My guess is best approach is to set dominant language a close as possible, then train a model as discussed by others. 我的猜测是最好的方法是尽可能地设置主导语言,然后训练其他人讨论的模型。

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

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