iOS पर एमएल किट की मदद से डिजिटल इंक की पहचान करना

ML Kit की डिजिटल इंक की पहचान करने की सुविधा की मदद से, डिजिटल प्लैटफ़ॉर्म पर हाथ से लिखे गए टेक्स्ट को सैकड़ों भाषाओं में पहचाना जा सकता है. साथ ही, स्केच को अलग-अलग कैटगरी में बांटा जा सकता है.

इसे आज़माएं

शुरू करने से पहले

  1. अपनी Podfile में, ये ML Kit लाइब्रेरी शामिल करें:

    pod 'GoogleMLKit/DigitalInkRecognition', '8.0.0'
    
    
  2. अपने प्रोजेक्ट के Pods को इंस्टॉल या अपडेट करने के बाद, .xcworkspace का इस्तेमाल करके अपना Xcode प्रोजेक्ट खोलें. ML Kit, Xcode के वर्शन 13.2.1 या इसके बाद के वर्शन पर काम करता है.

अब Ink ऑब्जेक्ट में मौजूद टेक्स्ट को पहचाना जा सकता है.

Ink ऑब्जेक्ट बनाना

Ink ऑब्जेक्ट बनाने का मुख्य तरीका, उसे टच स्क्रीन पर ड्रॉ करना है. iOS पर, UIImageView का इस्तेमाल टच इवेंट हैंडलर के साथ किया जा सकता है. ये स्क्रीन पर स्ट्रोक बनाते हैं और Ink ऑब्जेक्ट बनाने के लिए, स्ट्रोक के पॉइंट भी सेव करते हैं. इस सामान्य पैटर्न को यहां दिए गए कोड स्निपेट में दिखाया गया है. ज़्यादा जानकारी वाले उदाहरण के लिए, क्विकस्टार्ट ऐप्लिकेशन देखें. इसमें टच इवेंट को मैनेज करने, स्क्रीन ड्रॉइंग, और स्ट्रोक डेटा मैनेजमेंट को अलग-अलग किया गया है.

Swift

@IBOutlet weak var mainImageView: UIImageView!
var kMillisecondsPerTimeInterval = 1000.0
var lastPoint = CGPoint.zero
private var strokes: [Stroke] = []
private var points: [StrokePoint] = []

func drawLine(from fromPoint: CGPoint, to toPoint: CGPoint) {
  UIGraphicsBeginImageContext(view.frame.size)
  guard let context = UIGraphicsGetCurrentContext() else {
    return
  }
  mainImageView.image?.draw(in: view.bounds)
  context.move(to: fromPoint)
  context.addLine(to: toPoint)
  context.setLineCap(.round)
  context.setBlendMode(.normal)
  context.setLineWidth(10.0)
  context.setStrokeColor(UIColor.white.cgColor)
  context.strokePath()
  mainImageView.image = UIGraphicsGetImageFromCurrentImageContext()
  mainImageView.alpha = 1.0
  UIGraphicsEndImageContext()
}

override func touchesBegan(_ touches: Set, with event: UIEvent?) {
  guard let touch = touches.first else {
    return
  }
  lastPoint = touch.location(in: mainImageView)
  let t = touch.timestamp
  points = [StrokePoint.init(x: Float(lastPoint.x),
                             y: Float(lastPoint.y),
                             t: Int(t * kMillisecondsPerTimeInterval))]
  drawLine(from:lastPoint, to:lastPoint)
}

override func touchesMoved(_ touches: Set, with event: UIEvent?) {
  guard let touch = touches.first else {
    return
  }
  let currentPoint = touch.location(in: mainImageView)
  let t = touch.timestamp
  points.append(StrokePoint.init(x: Float(currentPoint.x),
                                 y: Float(currentPoint.y),
                                 t: Int(t * kMillisecondsPerTimeInterval)))
  drawLine(from: lastPoint, to: currentPoint)
  lastPoint = currentPoint
}

override func touchesEnded(_ touches: Set, with event: UIEvent?) {
  guard let touch = touches.first else {
    return
  }
  let currentPoint = touch.location(in: mainImageView)
  let t = touch.timestamp
  points.append(StrokePoint.init(x: Float(currentPoint.x),
                                 y: Float(currentPoint.y),
                                 t: Int(t * kMillisecondsPerTimeInterval)))
  drawLine(from: lastPoint, to: currentPoint)
  lastPoint = currentPoint
  strokes.append(Stroke.init(points: points))
  self.points = []
  doRecognition()
}

Objective-C

// Interface
@property (weak, nonatomic) IBOutlet UIImageView *mainImageView;
@property(nonatomic) CGPoint lastPoint;
@property(nonatomic) NSMutableArray *strokes;
@property(nonatomic) NSMutableArray *points;

// Implementations
static const double kMillisecondsPerTimeInterval = 1000.0;

- (void)drawLineFrom:(CGPoint)fromPoint to:(CGPoint)toPoint {
  UIGraphicsBeginImageContext(self.mainImageView.frame.size);
  [self.mainImageView.image drawInRect:CGRectMake(0, 0, self.mainImageView.frame.size.width,
                                                  self.mainImageView.frame.size.height)];
  CGContextMoveToPoint(UIGraphicsGetCurrentContext(), fromPoint.x, fromPoint.y);
  CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), toPoint.x, toPoint.y);
  CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
  CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10.0);
  CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 1, 1, 1);
  CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeNormal);
  CGContextStrokePath(UIGraphicsGetCurrentContext());
  CGContextFlush(UIGraphicsGetCurrentContext());
  self.mainImageView.image = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
}

- (void)touchesBegan:(NSSet *)touches withEvent:(nullable UIEvent *)event {
  UITouch *touch = [touches anyObject];
  self.lastPoint = [touch locationInView:self.mainImageView];
  NSTimeInterval time = [touch timestamp];
  self.points = [NSMutableArray array];
  [self.points addObject:[[MLKStrokePoint alloc] initWithX:self.lastPoint.x
                                                         y:self.lastPoint.y
                                                         t:time * kMillisecondsPerTimeInterval]];
  [self drawLineFrom:self.lastPoint to:self.lastPoint];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(nullable UIEvent *)event {
  UITouch *touch = [touches anyObject];
  CGPoint currentPoint = [touch locationInView:self.mainImageView];
  NSTimeInterval time = [touch timestamp];
  [self.points addObject:[[MLKStrokePoint alloc] initWithX:currentPoint.x
                                                         y:currentPoint.y
                                                         t:time * kMillisecondsPerTimeInterval]];
  [self drawLineFrom:self.lastPoint to:currentPoint];
  self.lastPoint = currentPoint;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(nullable UIEvent *)event {
  UITouch *touch = [touches anyObject];
  CGPoint currentPoint = [touch locationInView:self.mainImageView];
  NSTimeInterval time = [touch timestamp];
  [self.points addObject:[[MLKStrokePoint alloc] initWithX:currentPoint.x
                                                         y:currentPoint.y
                                                         t:time * kMillisecondsPerTimeInterval]];
  [self drawLineFrom:self.lastPoint to:currentPoint];
  self.lastPoint = currentPoint;
  if (self.strokes == nil) {
    self.strokes = [NSMutableArray array];
  }
  [self.strokes addObject:[[MLKStroke alloc] initWithPoints:self.points]];
  self.points = nil;
  [self doRecognition];
}

ध्यान दें कि कोड स्निपेट में एक सैंपल फ़ंक्शन शामिल होता है, ताकि स्ट्रोक को UIImageView में ड्रॉ किया जा सके. इसे आपके ऐप्लिकेशन के लिए ज़रूरत के हिसाब से अडजस्ट किया जाना चाहिए. हमारा सुझाव है कि लाइन सेगमेंट बनाते समय राउंडकैप का इस्तेमाल करें, ताकि शून्य लंबाई वाले सेगमेंट को बिंदु के तौर पर बनाया जा सके. जैसे, अंग्रेज़ी के छोटे अक्षर i पर बना बिंदु. doRecognition() फ़ंक्शन को हर स्ट्रोक के लिखे जाने के बाद कॉल किया जाता है. इसके बारे में यहां बताया गया है.

DigitalInkRecognizer का कोई इंस्टेंस पाएं

पहचान करने के लिए, हमें Ink ऑब्जेक्ट को DigitalInkRecognizer इंस्टेंस में पास करना होगा. DigitalInkRecognizer इंस्टेंस पाने के लिए, हमें सबसे पहले अपनी पसंद की भाषा के लिए, पहचान करने वाला मॉडल डाउनलोड करना होगा. इसके बाद, मॉडल को रैम में लोड करना होगा. इसके लिए, यहां दिए गए कोड स्निपेट का इस्तेमाल किया जा सकता है. इसे आसानी से समझने के लिए, viewDidLoad() तरीके में रखा गया है. साथ ही, इसमें हार्डकोड की गई भाषा के नाम का इस्तेमाल किया गया है. उपयोगकर्ता को उपलब्ध भाषाओं की सूची दिखाने और चुनी गई भाषा को डाउनलोड करने का उदाहरण देखने के लिए, क्विकस्टार्ट ऐप्लिकेशन देखें.

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  let languageTag = "en-US"
  let identifier = DigitalInkRecognitionModelIdentifier(forLanguageTag: languageTag)
  if identifier == nil {
    // no model was found or the language tag couldn't be parsed, handle error.
  }
  let model = DigitalInkRecognitionModel.init(modelIdentifier: identifier!)
  let modelManager = ModelManager.modelManager()
  let conditions = ModelDownloadConditions.init(allowsCellularAccess: true,
                                         allowsBackgroundDownloading: true)
  modelManager.download(model, conditions: conditions)
  // Get a recognizer for the language
  let options: DigitalInkRecognizerOptions = DigitalInkRecognizerOptions.init(model: model)
  recognizer = DigitalInkRecognizer.digitalInkRecognizer(options: options)
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  NSString *languagetag = @"en-US";
  MLKDigitalInkRecognitionModelIdentifier *identifier =
      [MLKDigitalInkRecognitionModelIdentifier modelIdentifierForLanguageTag:languagetag];
  if (identifier == nil) {
    // no model was found or the language tag couldn't be parsed, handle error.
  }
  MLKDigitalInkRecognitionModel *model = [[MLKDigitalInkRecognitionModel alloc]
                                          initWithModelIdentifier:identifier];
  MLKModelManager *modelManager = [MLKModelManager modelManager];
  [modelManager downloadModel:model conditions:[[MLKModelDownloadConditions alloc]
                                                initWithAllowsCellularAccess:YES
                                                allowsBackgroundDownloading:YES]];
  MLKDigitalInkRecognizerOptions *options =
      [[MLKDigitalInkRecognizerOptions alloc] initWithModel:model];
  self.recognizer = [MLKDigitalInkRecognizer digitalInkRecognizerWithOptions:options];
}

क्विकस्टार्ट ऐप्लिकेशन में अतिरिक्त कोड शामिल होता है. इससे पता चलता है कि एक ही समय पर कई डाउनलोड कैसे मैनेज किए जा सकते हैं. साथ ही, डाउनलोड पूरा होने की सूचनाओं को मैनेज करके, यह कैसे पता लगाया जा सकता है कि कौनसा डाउनलोड पूरा हुआ.

Ink ऑब्जेक्ट की पहचान करना

इसके बाद, हम doRecognition() फ़ंक्शन पर आते हैं. इसे आसानी से समझने के लिए, touchesEnded() से कॉल किया जाता है. अन्य ऐप्लिकेशन में, हो सकता है कि कोई व्यक्ति टाइम आउट के बाद ही पहचान की सुविधा को चालू करना चाहे या जब उपयोगकर्ता ने पहचान की सुविधा को ट्रिगर करने के लिए कोई बटन दबाया हो.

Swift

func doRecognition() {
  let ink = Ink.init(strokes: strokes)
  recognizer.recognize(
    ink: ink,
    completion: {
      [unowned self]
      (result: DigitalInkRecognitionResult?, error: Error?) in
      var alertTitle = ""
      var alertText = ""
      if let result = result, let candidate = result.candidates.first {
        alertTitle = "I recognized this:"
        alertText = candidate.text
      } else {
        alertTitle = "I hit an error:"
        alertText = error!.localizedDescription
      }
      let alert = UIAlertController(title: alertTitle,
                                  message: alertText,
                           preferredStyle: UIAlertController.Style.alert)
      alert.addAction(UIAlertAction(title: "OK",
                                    style: UIAlertAction.Style.default,
                                  handler: nil))
      self.present(alert, animated: true, completion: nil)
    }
  )
}

Objective-C

- (void)doRecognition {
  MLKInk *ink = [[MLKInk alloc] initWithStrokes:self.strokes];
  __weak typeof(self) weakSelf = self;
  [self.recognizer
      recognizeInk:ink
        completion:^(MLKDigitalInkRecognitionResult *_Nullable result,
                     NSError *_Nullable error) {
    typeof(weakSelf) strongSelf = weakSelf;
    if (strongSelf == nil) {
      return;
    }
    NSString *alertTitle = nil;
    NSString *alertText = nil;
    if (result.candidates.count > 0) {
      alertTitle = @"I recognized this:";
      alertText = result.candidates[0].text;
    } else {
      alertTitle = @"I hit an error:";
      alertText = [error localizedDescription];
    }
    UIAlertController *alert =
        [UIAlertController alertControllerWithTitle:alertTitle
                                            message:alertText
                                     preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:[UIAlertAction actionWithTitle:@"OK"
                                              style:UIAlertActionStyleDefault
                                            handler:nil]];
    [strongSelf presentViewController:alert animated:YES completion:nil];
  }];
}

मॉडल डाउनलोड मैनेज करना

हमने पहले ही देख लिया है कि पहचान करने वाला मॉडल कैसे डाउनलोड किया जाता है. यहां दिए गए कोड स्निपेट से पता चलता है कि कोई मॉडल पहले से डाउनलोड किया गया है या नहीं. इसके अलावा, स्टोरेज खाली करने के लिए, किसी मॉडल को मिटाने का तरीका भी बताया गया है.

यह देखना कि कोई मॉडल पहले से डाउनलोड किया गया है या नहीं

Swift

let model : DigitalInkRecognitionModel = ...
let modelManager = ModelManager.modelManager()
modelManager.isModelDownloaded(model)

Objective-C

MLKDigitalInkRecognitionModel *model = ...;
MLKModelManager *modelManager = [MLKModelManager modelManager];
[modelManager isModelDownloaded:model];

डाउनलोड किया गया कोई मॉडल मिटाना

Swift

let model : DigitalInkRecognitionModel = ...
let modelManager = ModelManager.modelManager()

if modelManager.isModelDownloaded(model) {
  modelManager.deleteDownloadedModel(
    model!,
    completion: {
      error in
      if error != nil {
        // Handle error
        return
      }
      NSLog(@"Model deleted.");
    })
}

Objective-C

MLKDigitalInkRecognitionModel *model = ...;
MLKModelManager *modelManager = [MLKModelManager modelManager];

if ([self.modelManager isModelDownloaded:model]) {
  [self.modelManager deleteDownloadedModel:model
                                completion:^(NSError *_Nullable error) {
                                  if (error) {
                                    // Handle error.
                                    return;
                                  }
                                  NSLog(@"Model deleted.");
                                }];
}

टेक्स्ट पहचानने की सुविधा को ज़्यादा सटीक बनाने के लिए सलाह

टेक्स्ट की पहचान करने की सुविधा की सटीकता, अलग-अलग भाषाओं के हिसाब से अलग-अलग हो सकती है. नतीजे कितने सटीक होंगे, यह इस बात पर भी निर्भर करता है कि लिखने का तरीका क्या है. डिजिटल इंक रिकग्निशन को कई तरह की लिखावट शैलियों को समझने के लिए ट्रेन किया गया है. हालांकि, इसके नतीजे हर उपयोगकर्ता के लिए अलग-अलग हो सकते हैं.

टेक्स्ट पहचानने की सुविधा को ज़्यादा सटीक बनाने के लिए, यहां कुछ तरीके दिए गए हैं. ध्यान दें कि ये तकनीकें, इमोजी, ऑटोड्रॉ, और शेप के लिए ड्रॉइंग क्लासिफ़ायर पर लागू नहीं होती हैं.

लिखने की जगह

कई ऐप्लिकेशन में, उपयोगकर्ता के इनपुट के लिए लिखने की जगह को अच्छी तरह से तय किया गया है. किसी सिंबल का मतलब, कुछ हद तक उसके साइज़ से तय होता है. यह साइज़, उस राइटिंग एरिया के साइज़ के हिसाब से तय होता है जिसमें वह सिंबल मौजूद होता है. उदाहरण के लिए, लोअर या अपर केस लेटर "o" या "c" के बीच का अंतर और कॉमा बनाम फ़ॉरवर्ड स्लैश.

लिखने की जगह की चौड़ाई और ऊंचाई की जानकारी देने से, लिखावट पहचानने की सुविधा को ज़्यादा सटीक बनाया जा सकता है. हालांकि, लिखावट पहचानने वाला टूल यह मानकर चलता है कि लिखने की जगह पर सिर्फ़ एक लाइन का टेक्स्ट है. अगर लिखने की जगह इतनी बड़ी है कि उपयोगकर्ता दो या उससे ज़्यादा लाइनें लिख सकता है, तो आपको बेहतर नतीजे मिल सकते हैं. इसके लिए, WritingArea में ऐसी ऊंचाई पास करें जो आपके हिसाब से, टेक्स्ट की एक लाइन की ऊंचाई का सबसे सही अनुमान हो. यह ज़रूरी नहीं है कि आपने पहचान करने वाले टूल को जो WritingArea ऑब्जेक्ट पास किया है वह स्क्रीन पर मौजूद फ़िज़िकल राइटिंग एरिया से पूरी तरह मेल खाता हो. इस तरह से WritingArea की ऊंचाई बदलने पर, यह कुछ भाषाओं में दूसरों की तुलना में बेहतर काम करता है.

लिखने की जगह तय करते समय, उसकी चौड़ाई और ऊंचाई को स्ट्रोक कोऑर्डिनेट वाली यूनिट में ही तय करें. x,y कोऑर्डिनेट आर्ग्युमेंट के लिए, किसी यूनिट की ज़रूरत नहीं होती. एपीआई सभी यूनिट को सामान्य बनाता है. इसलिए, स्ट्रोक का साइज़ और पोज़िशन ही मायने रखती है. आपके पास अपने सिस्टम के हिसाब से, किसी भी स्केल में निर्देशांक पास करने की सुविधा होती है.

पहले से मौजूद कॉन्टेक्स्ट

प्री-कॉन्टेक्स्ट वह टेक्स्ट होता है जो Ink में मौजूद उन स्ट्रोक से ठीक पहले आता है जिन्हें पहचानने की कोशिश की जा रही है. आवाज़ पहचानने वाले सिस्टम को पहले के कॉन्टेक्स्ट के बारे में बताकर, उसकी मदद की जा सकती है.

उदाहरण के लिए, कर्सिव लेटर "n" और "u" को अक्सर एक-दूसरे के तौर पर समझ लिया जाता है. अगर उपयोगकर्ता ने पहले ही "arg" शब्द का कुछ हिस्सा डाल दिया है, तो वह ऐसे स्ट्रोक जारी रख सकता है जिन्हें "ument" या "nment" के तौर पर पहचाना जा सकता है. "arg" के पहले के कॉन्टेक्स्ट की जानकारी देने से, भ्रम की स्थिति दूर हो जाती है. ऐसा इसलिए, क्योंकि "argnment" के बजाय "argument" शब्द होने की संभावना ज़्यादा है.

प्री-कॉन्टेक्स्ट की मदद से, पहचान करने वाले सिस्टम को शब्दों के बीच के ब्रेक और स्पेस की पहचान करने में भी मदद मिल सकती है. स्पेस कैरेक्टर को टाइप किया जा सकता है, लेकिन उसे ड्रॉ नहीं किया जा सकता. ऐसे में, लिखावट पहचानने वाला सिस्टम यह कैसे तय कर सकता है कि कोई शब्द कब खत्म हो रहा है और अगला शब्द कब शुरू हो रहा है? अगर उपयोगकर्ता ने पहले ही "hello" लिख दिया है और वह "world" शब्द लिखना जारी रखता है, तो पहले से मौजूद कॉन्टेक्स्ट के बिना, पहचान करने वाला टूल "world" स्ट्रिंग दिखाता है. हालांकि, अगर आपने पहले से मौजूद कॉन्टेक्स्ट "hello" दिया है, तो मॉडल " world" स्ट्रिंग दिखाएगा. इसमें शुरुआत में स्पेस होगा, क्योंकि "helloword" के बजाय "hello world" ज़्यादा सही है.

आपको प्री-कॉन्टेक्स्ट स्ट्रिंग को ज़्यादा से ज़्यादा लंबा रखना चाहिए. इसमें स्पेस के साथ-साथ ज़्यादा से ज़्यादा 20 वर्ण हो सकते हैं. अगर स्ट्रिंग लंबी है, तो पहचान करने वाला सिस्टम सिर्फ़ आखिरी 20 वर्णों का इस्तेमाल करता है.

यहां दिए गए कोड सैंपल से, लिखने की जगह तय करने और पहले से मौजूद कॉन्टेक्स्ट की जानकारी देने के लिए, RecognitionContext ऑब्जेक्ट का इस्तेमाल करने का तरीका पता चलता है.

Swift

let ink: Ink = ...;
let recognizer: DigitalInkRecognizer =  ...;
let preContext: String = ...;
let writingArea = WritingArea.init(width: ..., height: ...);

let context: DigitalInkRecognitionContext.init(
    preContext: preContext,
    writingArea: writingArea);

recognizer.recognizeHandwriting(
  from: ink,
  context: context,
  completion: {
    (result: DigitalInkRecognitionResult?, error: Error?) in
    if let result = result, let candidate = result.candidates.first {
      NSLog("Recognized \(candidate.text)")
    } else {
      NSLog("Recognition error \(error)")
    }
  })

Objective-C

MLKInk *ink = ...;
MLKDigitalInkRecognizer *recognizer = ...;
NSString *preContext = ...;
MLKWritingArea *writingArea = [MLKWritingArea initWithWidth:...
                                              height:...];

MLKDigitalInkRecognitionContext *context = [MLKDigitalInkRecognitionContext
       initWithPreContext:preContext
       writingArea:writingArea];

[recognizer recognizeHandwritingFromInk:ink
            context:context
            completion:^(MLKDigitalInkRecognitionResult
                         *_Nullable result, NSError *_Nullable error) {
                               NSLog(@"Recognition result %@",
                                     result.candidates[0].text);
                         }];

स्ट्रोक का क्रम

स्ट्रोक के क्रम से, लिखावट पहचानने की सुविधा के सटीक होने पर असर पड़ता है. लिखावट पहचानने वाले सिस्टम को उम्मीद होती है कि स्ट्रोक उसी क्रम में होंगे जिस क्रम में लोग आम तौर पर लिखते हैं. उदाहरण के लिए, अंग्रेज़ी के लिए बाएं से दाएं. इस पैटर्न से अलग कोई भी केस, जैसे कि अंग्रेज़ी के वाक्य को आखिरी शब्द से शुरू करना, कम सटीक नतीजे देता है.

इसका एक और उदाहरण है, जब Ink के बीच में मौजूद किसी शब्द को हटाकर उसकी जगह कोई दूसरा शब्द इस्तेमाल किया जाता है. ऐसा हो सकता है कि बदलाव किसी वाक्य के बीच में हो, लेकिन बदलाव के लिए स्ट्रोक, स्ट्रोक के क्रम के आखिर में हों. इस मामले में, हमारा सुझाव है कि नए लिखे गए शब्द को एपीआई पर अलग से भेजें. साथ ही, अपने लॉजिक का इस्तेमाल करके, नतीजे को पहले से पहचाने गए शब्दों के साथ मर्ज करें.

अस्पष्ट आकारों से निपटना

कुछ मामलों में, पहचान करने वाले सिस्टम को दिए गए आकार का मतलब साफ़ नहीं होता. उदाहरण के लिए, बहुत ज़्यादा गोल किनारों वाले आयत को आयत या एलिप्स के तौर पर देखा जा सकता है.

ऐसे मामलों को हैंडल करने के लिए, पहचान के स्कोर का इस्तेमाल किया जा सकता है. हालांकि, इसके लिए ज़रूरी है कि ये स्कोर उपलब्ध हों. सिर्फ़ शेप क्लासिफ़ायर स्कोर देते हैं. अगर मॉडल को पूरा भरोसा है, तो सबसे अच्छे नतीजे का स्कोर, दूसरे सबसे अच्छे नतीजे के स्कोर से काफ़ी बेहतर होगा. अगर कोई अनिश्चितता है, तो टॉप दो नतीजों के स्कोर करीब होंगे. यह भी ध्यान रखें कि शेप क्लासिफ़ायर, पूरे Ink को एक ही शेप के तौर पर दिखाते हैं. उदाहरण के लिए, अगर Ink में एक-दूसरे के बगल में एक रेक्टैंगल और एक एलिप्स है, तो पहचान करने वाला टूल नतीजे के तौर पर एक या दूसरा (या पूरी तरह से अलग) दिखा सकता है. ऐसा इसलिए, क्योंकि पहचान करने वाला एक कैंडिडेट दो आकृतियों को नहीं दिखा सकता.