语言分析框架的词素分析已弃用 API 的替代品是什么 [英] What is the replacement for Language Analysis framework's Morpheme analysis deprecated APIs

查看:29
本文介绍了语言分析框架的词素分析已弃用 API 的替代品是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

语言分析框架已弃用,甚至在 64 位版本中也不可用.文档说 - 使用 CFStringTokenizer 但标记器不提供 lang 分析框架中可用的功能.

The Language Analysis framework is deprecated and its not even available in 64-bit. The documentation says - use CFStringTokenizer but the tokenizer doesn't provide functionalities available in lang analysis framework.

lang 分析框架提供的词素分析 API 的替代品是什么?

What is the replacement for morpheme analysis APIs that lang analysis framework provided?

尽管 Pantong 的回复有所帮助,但并非在所有情况下都有效,例如对于具有 3-4 个汉字字符的单词,它返回不正确的结果.(不正确我的意思是它与 Lang 分析框架 API 为同一字符串返回的不同).

Though Pantong's reply helped but it doesn't work in all cases, e.g. for words with 3-4 kanji characters it returns incorrect result. (By incorrect I mean its not same as what it returned by Lang analysis framework API for same string).

a) 现人神被转换为拉丁语 - 'gen ren shen' 和平假名 - 'げんじんしん' 而它应该是 - 拉丁语 - 'Arahitogami' 和平假名 - 'あらひとがみ'

a) 現人神 is converted to latin - 'gen ren shen' and in hiragana- 'げんじんしん' whereas it should be - in latin - 'Arahitogami ' and in hiragana- 'あらひとがみ'

b) 安本丹被转换为拉丁语 - 'an ben dan' 和平假名 - 'やすもとまこと' 而它应该是 - 在拉丁语中 - 'Yasumoto makoto' 和平假名 - 'あんぽんたん'

b) 安本丹 is converted to latin - 'an ben dan' and in hiragana- 'やすもとまこと' whereas it should be - in latin as - 'Yasumoto makoto ' and in hiragana- 'あんぽんたん'

推荐答案

已弃用的语素分析 API 的一个功能是为日文/中文文本获取红润文本".如果您要求更换该特定功能,则以下代码是一个示例.但是,我不知道词素分析 API 中其他功能的替代品.

One feature the deprecated morpheme analysis APIs has is "getting rudy text for Japanese/Chinese text". If you asking the replacement for that particular feature, then the following code is an example. However, I don't know about the replacement for other features in morpheme analysis APIs.

CFStringRef testString = CFSTR("のちに検知されたトークンの範囲用として使用");

CFStringTokenizerRef tokenizer = CFStringTokenizerCreate(kCFAllocatorDefault,
                                                         testString,
                                                         CFRangeMake(0, CFStringGetLength(testString)),
                                                         kCFStringTokenizerUnitWordBoundary,
                                                         CFLocaleCreate(kCFAllocatorDefault, CFSTR("Japanese")));
do
{
    if (CFStringTokenizerAdvanceToNextToken(tokenizer) == kCFStringTokenizerTokenNone) {
        break;
    }

    CFStringRef originalToken = CFStringCreateWithSubstring(kCFAllocatorDefault,
                                                            testString,
                                                            CFStringTokenizerGetCurrentTokenRange(tokenizer));

    // Get Latin transcription from the Japanese text
    CFMutableStringRef convertedToken = (CFMutableStringRef)CFStringTokenizerCopyCurrentTokenAttribute(tokenizer,
                                                                            kCFStringTokenizerAttributeLatinTranscription);
    NSLog(@"token: %@ -> latin: %@", originalToken, convertedToken);

    // Get kana from Latin transcription
    CFStringTransform(convertedToken, NULL, kCFStringTransformLatinHiragana, false);
    NSLog(@"token: %@ -> latin: %@", originalToken, convertedToken);
}
while (true);

这篇关于语言分析框架的词素分析已弃用 API 的替代品是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆