gpt4 book ai didi

iphone - 获取字符串的语言

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:54:47 26 4
gpt4 key购买 nike

假设我有一个用不同语言编写的标题字符串。

有没有办法检查每个字符串是哪种语言?

最佳答案

我没有玩过它,但你应该看看 NSLinguisticTagger及其 - (NSOrthography *)orthographyAtIndex:(NSUInteger)charIndex effectiveRange:(NSRangePointer)effectiveRange 方法。来自NSOrthography docs :

The NSOrthography class describes the linguistic content of a piece of text, typically used for the purposes of spelling and grammar checking.

An NSOrthography instance describes:

Which scripts the text contains. A dominant language and possibly other languages for each of these scripts. A dominant script and language for the text as a whole. Scripts are uniformly described by standard four-letter tags (Latn, Grek, Cyrl, etc.) with the supertags Jpan and Kore typically used for Japanese and Korean text, Hans and Hant for Chinese text; the tag Zyyy is used if a specific script cannot be identified. See Internationalization Programming Topics for more information on internationalization.

Languages are uniformly described by BCP-47 tags , preferably in canonical form; the tag und is used if a specific language cannot be determined.

关于iphone - 获取字符串的语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13246449/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com