# MLKitDigitalInkRecognition Framework Reference

# DigitalInkRecognitionModelIdentifier

    class DigitalInkRecognitionModelIdentifier : NSObject

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


  ### [languageTag](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)languageTag)


  ` BCP 47 conformant language tag for this model.

  #### Declaration

  Swift

      var languageTag: String { get }

- `


  ### [languageSubtag](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)languageSubtag)


  ` 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 }

- `


  ### [scriptSubtag](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)scriptSubtag)


  ` 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 }

- `


  ### [regionSubtag](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)regionSubtag)


  ` 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 }

- `


  ### [-init](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(im)init)


  ` Use `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(cm)modelIdentifierFromLanguageTag:error:` instead.
- `


  ### [from(languageTag:)](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(cm)modelIdentifierFromLanguageTag:error:)


  ` Returns A model identifier that best matches the language, script (if
  any), and region (if any) encoded in the BCP 47 formatted `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)languageTag`.

  <br />

  The matching is best-effort, i.e. it returns the model identifier that
  best matches the provided `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)languageTag` using the following heuristics:

  <br />

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

    <br />

    <br />

  - If no script is provided, and no script is implicit for the requested language subtag, match against any script.<br />

    <br />

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

    <br />

    <br />

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

    <br />

    <br />

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

    <br />

    If no model identifier can be found, returns `nil`.

  #### Declaration

  Swift

      class func from(languageTag: String) throws -> DigitalInkRecognitionModelIdentifier

  #### Parameters

  |---|---|
  | ` languageTag ` | An IETF BCP 47 language tag representing the requested language. |
  | ` error ` | Optional error message object, will be populated if the `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)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.
- `


  ### [init(forLanguageTag:)](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(cm)modelIdentifierForLanguageTag:)


  ` Returns a model identifier that matches the given `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)languageTag` exactly.

  <br />

  Differs from `from(LanguageTag:)` in that it does not attempt to parse the `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)languageTag`
  (and thus does not generate errors), and just returns the model identifier that matches
  `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)languageTag` exactly, if it exists.

  #### Declaration

  Swift

      /*not inherited*/ init?(forLanguageTag languageTag: String)

  #### Parameters

  |---|---|
  | ` languageTag ` | The IETF BCP 47 language tag of the requested model identifier. |

  #### Return Value

  A `DigitalInkRecognitionModelIdentifier` matching the provided `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)languageTag` exactly, or
  `nil` if none was found.
- `


  ### [allModelIdentifiers()](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(cm)allModelIdentifiers)


  ` Returns the set of all available model identifiers.

  #### Declaration

  Swift

      class func allModelIdentifiers() -> Set<DigitalInkRecognitionModelIdentifier>

- `


  ### [modelIdentifiers(forLanguageSubtag:)](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(cm)modelIdentifiersForLanguageSubtag:)


  ` 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 `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Constants.html#/c:@MLKDigitalInkRecognitionModelIdentifierEnUs`
  (English, United States), `enUk` (English, United Kingdom), `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Constants.html#/c:@MLKDigitalInkRecognitionModelIdentifierEnKe` (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

  |---|---|
  | ` 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 `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)languageSubtag`, may be empty.
- `


  ### [modelIdentifiers(forScriptSubtag:)](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(cm)modelIdentifiersForScriptSubtag:)


  ` 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
  `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Constants.html#/c:@MLKDigitalInkRecognitionModelIdentifierEnUs` (English, United States), `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Constants.html#/c:@MLKDigitalInkRecognitionModelIdentifierFrFr` (French, France), `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Constants.html#/c:@MLKDigitalInkRecognitionModelIdentifierGuLatn` (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

  Swift

      class func modelIdentifiers(forScriptSubtag scriptSubtag: String) -> Set<DigitalInkRecognitionModelIdentifier>

  #### 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 `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)scriptSubtag`, may be empty.
- `


  ### [modelIdentifiers(forRegionSubtag:)](https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(cm)modelIdentifiersForRegionSubtag:)


  ` 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 `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Constants.html#/c:@MLKDigitalInkRecognitionModelIdentifierDeCh` (German,
  Switzerland), `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Constants.html#/c:@MLKDigitalInkRecognitionModelIdentifierFrCh` (French, Switzerland), `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Constants.html#/c:@MLKDigitalInkRecognitionModelIdentifierItCh` (Italian, Switzerland), and `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Constants.html#/c:@MLKDigitalInkRecognitionModelIdentifierRmCh` (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

  Swift

      class func modelIdentifiers(forRegionSubtag regionSubtag: String) -> Set<DigitalInkRecognitionModelIdentifier>

  #### 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 `https://developers.google.com/ml-kit/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier.html#/c:objc(cs)MLKDigitalInkRecognitionModelIdentifier(py)regionSubtag`, may be
  empty.