AI-generated Key Takeaways
-
DigitalInkRecognitionModelIdentifierrepresents a digital ink recognition model based on language, script, and optional regional variant. -
It provides methods to retrieve model identifiers based on language tags, subtags (language, script, region), or to get all available identifiers.
-
The
from(languageTag:)method offers best-effort matching, considering macrolanguages, script subsets, and regional variations to find the most suitable model. -
init(forLanguageTag:)provides exact matching for a given language tag, returning the identifier if it exists, without parsing or error generation. -
Developers can utilize these methods to identify and select appropriate recognition models for their specific language and regional needs.
DigitalInkRecognitionModelIdentifier
class DigitalInkRecognitionModelIdentifier : NSObjectRepresents a digital ink recognition model specific to a language, script, and optionally a regional variant.
-
BCP 47 conformant language tag for this model.
Declaration
Swift
var languageTag: String { get } -
Language subtag, i.e. the 2 or 3-letter ISO 639 language code for this recognition model, e.g.
"en"for English.Declaration
Swift
var languageSubtag: String { get } -
Script subtag, i.e. the four-letter ISO 15924 standard code of the script used in this recognition model, e.g.
"Latn"for Latin script or"Arab"for Arabic script.Declaration
Swift
var scriptSubtag: String? { get } -
Region subtag, i.e. the two-letter ISO 3166-1 Alpha 2 standard region codes or the set of numeric codes defined by the UN M.49 standard, e.g.
"DE"for Germany or"002"for Africa.Declaration
Swift
var regionSubtag: String? { get } -
Use
from(languageTag:)instead. -
Returns A model identifier that best matches the language, script (if any), and region (if any) encoded in the BCP 47 formatted
languageTag.The matching is best-effort, i.e. it returns the model identifier that best matches the provided
languageTagusing the following heuristics:- If no model identifier can be found for the requested language subtag, but the latter is part of a supported macrolanguage, match against the macrolanguage, e.g.
"arb"(Standard Arabic) will match"ar"(Arabic).- If no script is provided, and no script is implicit for the requested language subtag, match against any script.
- If the provided or implicit script subtag is a subset of a supported script, match against the latter as well, e.g.
"zh-Hant"(Chinese, Traditional Han) will match against"zh-Hani"(Chinese, Han).- If no region subtag is specified, match against any region, preferring model identifiers that also do not specify a region, e.g.
"ro"(Romanian) will match"ro-RO"(Romanian, Romania).- If a region subtag is specified, but cannot be matched, match against regions containing the specified region, e.g.
"fr-DZ"(French, Algeria) will match against"fr-002"(French, Africa).If no model identifier can be found, returns
nil.Declaration
Swift
class func from(languageTag: String) throws -> DigitalInkRecognitionModelIdentifierParameters
languageTagAn IETF BCP 47 language tag representing the requested language.
errorOptional error message object, will be populated if the
languageTagcannot be parsed.Return Value
a model identifier exactly matching the language tag provided, or the best approximate match, or
nilif no appropriate model identifier can be found. Also set tonilif the language tag could not be parsed. - If no model identifier can be found for the requested language subtag, but the latter is part of a supported macrolanguage, match against the macrolanguage, e.g.
-
Returns a model identifier that matches the given
languageTagexactly.Differs from
from(LanguageTag:)in that it does not attempt to parse thelanguageTag(and thus does not generate errors), and just returns the model identifier that matcheslanguageTagexactly, if it exists.Declaration
Swift
/*not inherited*/ init?(forLanguageTag languageTag: String)Parameters
languageTagThe IETF BCP 47 language tag of the requested model identifier.
Return Value
A
DigitalInkRecognitionModelIdentifiermatching the providedlanguageTagexactly, ornilif none was found. -
Returns the set of all available model identifiers.
Declaration
Swift
class func allModelIdentifiers() -> Set<DigitalInkRecognitionModelIdentifier> -
Returns the set of model identifiers that support the given language subtag.
E.g. for
"en", this would return a set of model identifiers containingenUs(English, United States),enUk(English, United Kingdom),enKe(English, Kenya), etc.If no model identifiers supporting the language subtag can be found, returns an empty set.
Declaration
Swift
class func modelIdentifiers(forLanguageSubtag languageSubtag: String) -> Set<DigitalInkRecognitionModelIdentifier>Parameters
languageSubtagA 2 or 3-letter ISO 639 language code, e.g.
"en"for English.Return Value
A set of model identifiers that support the provided
languageSubtag, may be empty. -
Returns the set of model identifiers that support the given script subtag.
E.g. for
"Latn", this would return a set of model identifiers containingenUs(English, United States),frFr(French, France),guLatn(Gujarati, Latin script), etc.This function also returns model identifiers that support a superset of the given script subtag, e.g. for
Hant(Han, Traditional variant), this function will return thezh-Hanirecognition models sinceHantis a subset ofHani(Han, both Traditional and Simplified variants).If no model identifiers supporting the script subtag can be found, returns an empty set.
Declaration
Swift
class func modelIdentifiers(forScriptSubtag scriptSubtag: String) -> Set<DigitalInkRecognitionModelIdentifier>Parameters
scriptSubtagA four-letter ISO 15924 standard code, e.g.
"Latn"for Latin script or"Arab"for Arabic script.Return Value
A set of model identifiers that support the provided
scriptSubtag, may be empty. -
Returns the set of model identifiers that are specific to the given region subtag.
E.g. for
"CH", this would return a set of model identifiers containingdeCh(German, Switzerland),frCh(French, Switzerland),itCh(Italian, Switzerland), andrmCh(Romansh, Switzerland).This function also returns model identifiers specific to regions that contain the given region subtag, or are contained by the given region subtag, e.g. searching for
DZ(Algeria) will produce results that include thefr-002(French, Africa) recognition model, and vice-versa.If no model identifiers supporting the region subtag can be found, returns an empty set.
Declaration
Swift
class func modelIdentifiers(forRegionSubtag regionSubtag: String) -> Set<DigitalInkRecognitionModelIdentifier>Parameters
regionSubtagA two-letter ISO 3166-1 Alpha 2 standard region code or one of the numeric codes defined by the UN M.49 standard, e.g.
"DE"for Germany or"002"for Africa.Return Value
A set of model identifiers that are specific to the provided
regionSubtag, may be empty.