Page Summary
-
The
MLKLanguageIdentificationclass identifies the primary language or potential languages within a given text. -
It offers methods to get an instance with default or custom options using
languageIdentificationandlanguageIdentificationWithOptions:. -
The
identifyLanguageForText:completion:method determines the main language, whileidentifyPossibleLanguagesForText:completion:identifies multiple potential languages. -
Both identification methods process text input (truncated to 200 characters for optimal accuracy) and provide results via completion handlers.
MLKLanguageIdentification
@interface MLKLanguageIdentification : NSObjectThe LanguageIdentification class that identifies the main language or possible languages for
the given text.
-
Gets a language identification instance with the default options.
Declaration
Objective-C
+ (nonnull MLKLanguageIdentification *)languageIdentification;Return Value
A new instance of
LanguageIdentificationwith the default options. -
Gets a language identification instance with the given options.
Declaration
Objective-C
+ (nonnull MLKLanguageIdentification *)languageIdentificationWithOptions: (nonnull MLKLanguageIdentificationOptions *)options;Parameters
optionsThe options used for language identification.
Return Value
A new instance of
LanguageIdentificationwith the given options. -
Identifies the main language for the given text.
Declaration
Objective-C
- (void)identifyLanguageForText:(nonnull NSString *)text completion:(nonnull MLKIdentifyLanguageCallback)completion;Parameters
textThe input text to use for identifying the language. Inputs longer than 200 characters are truncated to 200 characters, as longer input does not improve the detection accuracy.
completionHandler to call back on the main queue with the identified language tag or error.
-
Identifies possible languages for the given text.
Declaration
Objective-C
- (void)identifyPossibleLanguagesForText:(nonnull NSString *)text completion: (nonnull MLKIdentifyPossibleLanguagesCallback) completion;Parameters
textThe input text to use for identifying the language. Inputs longer than 200 characters are truncated to 200 characters, as longer input does not improve the detection accuracy.
completionHandler to call back on the main queue with identified languages or error.
-
Unavailable.
Declaration
Objective-C
- (nonnull instancetype)init;