AI-generated Key Takeaways
-
DigitalInkRecognitionContextprovides information about the context in which ink has been drawn, improving recognition quality. -
It includes
preContext(preceding characters) andwritingArea(size of the writing area) to aid the recognition process. -
These properties help the recognizer's language model to better understand and interpret the handwritten input.
-
Use
init(preContext:writingArea:)to create aDigitalInkRecognitionContextobject and pass it to aDigitalInkRecognizerfor improved results.
DigitalInkRecognitionContext
class DigitalInkRecognitionContext : 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
Swift
var preContext: String? { get } -
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
Swift
var writingArea: MLKWritingArea? { get } -
Unavailable. Use
init(preContext:writingArea:)instead. -
Creates a
DigitalInkRecognitionContextobject.Declaration
Swift
init(preContext: String?, writingArea: MLKWritingArea?)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.