MLKitDigitalInkRecognition Framework Reference

MLKDigitalInkRecognitionModelIdentifier


@interface MLKDigitalInkRecognitionModelIdentifier : NSObject

Represents a digital ink recognition model specific to a language, script, and optionally a regional variant.

  • BCP 47 conformant language tag for this model.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *_Nonnull languageTag;
  • Language subtag, i.e. the 2 or 3-letter ISO 639 language code for this recognition model, e.g. "en" for English.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *_Nonnull languageSubtag;
  • 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

    Objective-C

    @property (nonatomic, readonly, nullable) NSString *scriptSubtag;
  • 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

    Objective-C

    @property (nonatomic, readonly, nullable) NSString *regionSubtag;
  • Use from(languageTag:) instead.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • 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 languageTag using 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

    Objective-C

    + (nullable MLKDigitalInkRecognitionModelIdentifier *)
        modelIdentifierFromLanguageTag:(nonnull NSString *)languageTag
                                 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    languageTag

    An IETF BCP 47 language tag representing the requested language.

    error

    Optional error message object, will be populated if the languageTag cannot be parsed.

    Return Value

    a model identifier exactly matching the language tag provided, or the best approximate match, or nil if no appropriate model identifier can be found. Also set to nil if the language tag could not be parsed.

  • Returns a model identifier that matches the given languageTag exactly.

    Differs from from(LanguageTag:) in that it does not attempt to parse the languageTag (and thus does not generate errors), and just returns the model identifier that matches languageTag exactly, if it exists.

    Declaration

    Objective-C

    + (nullable MLKDigitalInkRecognitionModelIdentifier *)
        modelIdentifierForLanguageTag:(nonnull NSString *)languageTag;

    Parameters

    languageTag

    The IETF BCP 47 language tag of the requested model identifier.

    Return Value

    A DigitalInkRecognitionModelIdentifier matching the provided languageTag exactly, or nil if none was found.

  • Returns the set of all available model identifiers.

    Declaration

    Objective-C

    + (nonnull NSSet<MLKDigitalInkRecognitionModelIdentifier *> *)
        allModelIdentifiers;
  • Returns the set of model identifiers that support the given language subtag.

    E.g. for "en", this would return a set of model identifiers containing enUs (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

    Objective-C

    + (nonnull NSSet<MLKDigitalInkRecognitionModelIdentifier *> *)
        modelIdentifiersForLanguageSubtag:(nonnull NSString *)languageSubtag;

    Parameters

    languageSubtag

    A 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 containing enUs (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 the zh-Hani recognition models since Hant is a subset of Hani (Han, both Traditional and Simplified variants).

    If no model identifiers supporting the script subtag can be found, returns an empty set.

    Declaration

    Objective-C

    + (nonnull NSSet<MLKDigitalInkRecognitionModelIdentifier *> *)
        modelIdentifiersForScriptSubtag:(nonnull NSString *)scriptSubtag;

    Parameters

    scriptSubtag

    A 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 containing deCh (German, Switzerland), frCh (French, Switzerland), itCh (Italian, Switzerland), and rmCh (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 the fr-002 (French, Africa) recognition model, and vice-versa.

    If no model identifiers supporting the region subtag can be found, returns an empty set.

    Declaration

    Objective-C

    + (nonnull NSSet<MLKDigitalInkRecognitionModelIdentifier *> *)
        modelIdentifiersForRegionSubtag:(nonnull NSString *)regionSubtag;

    Parameters

    regionSubtag

    A 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.