MLKitDigitalInkRecognition Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
DigitalInkRecognitionContext
class DigitalInkRecognitionContext : NSObject
Information 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 }
-
-
Creates a DigitalInkRecognitionContext
object.
Declaration
Swift
init(preContext: String?, writingArea: MLKWritingArea?)
Parameters
preContext
|
Characters immediately before the position where the recognized text should
be inserted. See the description of the property with the same name for more details.
|
writingArea
|
Properties 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.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eDigitalInkRecognitionContext\u003c/code\u003e provides information about the context in which ink has been drawn, improving recognition quality.\u003c/p\u003e\n"],["\u003cp\u003eIt includes \u003ccode\u003epreContext\u003c/code\u003e (preceding characters) and \u003ccode\u003ewritingArea\u003c/code\u003e (size of the writing area) to aid the recognition process.\u003c/p\u003e\n"],["\u003cp\u003eThese properties help the recognizer's language model to better understand and interpret the handwritten input.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003einit(preContext:writingArea:)\u003c/code\u003e to create a \u003ccode\u003eDigitalInkRecognitionContext\u003c/code\u003e object and pass it to a \u003ccode\u003eDigitalInkRecognizer\u003c/code\u003e for improved results.\u003c/p\u003e\n"]]],["`DigitalInkRecognitionContext` provides context for ink recognition. Key actions include utilizing `preContext`, which denotes characters before the insertion point to enhance language model accuracy, ideally up to 20 characters. `writingArea` defines the drawing area's size, aiding in disambiguation. The class cannot be initialized directly; instead, use `init(preContext:writingArea:)` providing pre-context and writing area parameters to create the object. These are sent along with drawn ink for improved recognition.\n"],null,["# MLKitDigitalInkRecognition Framework Reference\n\nDigitalInkRecognitionContext\n============================\n\n class DigitalInkRecognitionContext : NSObject\n\nInformation about the context in which an ink has been drawn.\n\nPass this object to a [DigitalInkRecognizer](../Classes/DigitalInkRecognizer.html) alongside an ink to improve the recognition\nquality.\n- `\n ``\n ``\n `\n\n ### [preContext](#/c:objc(cs)MLKDigitalInkRecognitionContext(py)preContext)\n\n `\n ` \n Characters immediately before the position where the recognized text should be inserted.\n\n This information is used by the recognizer's language model to improve recognition.\n\n Example: a text field contains \"hello\", with the cursor right after \"o\". The user handwrites\n something that looks like \"world\". If the pre-context is set to \"hello\", the recognizer\n will be able to output \" world\", with a leading space.\n\n If the text field contains \"hello\" with the cursor between \"e\" and the first \"l\", then the\n pre-context must be set to \"he\".\n\n A good rule of thumb for pre-context length is: as many characters as possible, including spaces,\n until around 20. The optimal number depends on the exact recognition model that is used. Getting\n the best speed/accuracy tradeoff may require a bit of tuning. \n\n #### Declaration\n\n Swift \n\n var preContext: String? { get }\n\n- `\n ``\n ``\n `\n\n ### [writingArea](#/c:objc(cs)MLKDigitalInkRecognitionContext(py)writingArea)\n\n `\n ` \n Size of the writing area.\n\n This is used by some recognition models to disambiguate some cases. Example: lowercase vs.\n uppercase (\"o\" vs. \"O\").\n\n See also [WritingArea](../Classes/WritingArea.html). \n\n #### Declaration\n\n Swift \n\n var writingArea: MLKWritingArea? { get }\n\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)MLKDigitalInkRecognitionContext(im)init)\n\n `\n ` \n Unavailable. Use [init(preContext:writingArea:)](../Classes/DigitalInkRecognitionContext.html#/c:objc(cs)MLKDigitalInkRecognitionContext(im)initWithPreContext:writingArea:) instead.\n- `\n ``\n ``\n `\n\n ### [init(preContext:writingArea:)](#/c:objc(cs)MLKDigitalInkRecognitionContext(im)initWithPreContext:writingArea:)\n\n `\n ` \n Creates a `DigitalInkRecognitionContext` object. \n\n #### Declaration\n\n Swift \n\n init(preContext: String?, writingArea: MLKWritingArea?)\n\n #### Parameters\n\n |---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*preContext*` ` | Characters immediately before the position where the recognized text should be inserted. See the description of the property with the same name for more details. |\n | ` `*writingArea*` ` | Properties 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. |"]]