Page Summary
-
MLKDigitalInkRecognitionContext provides information about the context in which ink has been drawn, improving recognition quality when passed to a DigitalInkRecognizer along with the ink.
-
It includes properties like
preContext, representing preceding characters, andwritingArea, defining the size of the writing area, which aid in recognition accuracy. -
Developers should utilize the
initWithPreContext:writingArea:initializer to create an instance of this class, providing relevant contextual data. -
preContextshould ideally contain as many preceding characters as possible, up to around 20, to enhance recognition accuracy within the language model. -
The
writingAreaproperty helps disambiguate character recognition, especially in cases like lowercase versus uppercase letters.
MLKDigitalInkRecognitionContext
@interface MLKDigitalInkRecognitionContext : NSObjectInformation about the context in which an ink has been drawn.
Pass this object to a DigitalInkRecognizer alongside an ink to improve the recognition
quality.
-
Characters immediately before the position where the recognized text should be inserted.
This information is used by the recognizer’s language model to improve recognition.
Example: a text field contains “hello”, with the cursor right after “o”. The user handwrites something that looks like “world”. If the pre-context is set to “hello”, the recognizer will be able to output “ world”, with a leading space.
If the text field contains “hello” with the cursor between “e” and the first “l”, then the pre-context must be set to “he”.
A good rule of thumb for pre-context length is: as many characters as possible, including spaces, until around 20. The optimal number depends on the exact recognition model that is used. Getting the best speed/accuracy tradeoff may require a bit of tuning.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *preContext; -
Size of the writing area.
This is used by some recognition models to disambiguate some cases. Example: lowercase vs. uppercase (“o” vs. “O”).
See also
WritingArea.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKWritingArea *writingArea; -
Unavailable. Use
init(preContext:writingArea:)instead.Declaration
Objective-C
- (nonnull instancetype)init; -
Creates a
DigitalInkRecognitionContextobject.Declaration
Objective-C
- (nonnull instancetype)initWithPreContext:(nullable NSString *)preContext writingArea: (nullable MLKWritingArea *)writingArea;Parameters
preContextCharacters immediately before the position where the recognized text should be inserted. See the description of the property with the same name for more details.
writingAreaProperties of the region of the canvas where the ink has been drawn. See the description of the property with the same name for more details.