←Select platform

FeaturesProcessingEngine Class

Summary

The engine used to run the features on a document.

Syntax
C#
C++/CLI
Python
public class FeaturesProcessingEngine 
public: 
   ref class FeaturesProcessingEngine 
class FeaturesProcessingEngine: 
Example

This example runs a ruleset on a document and reads the results.

C#
using Leadtools; 
using Leadtools.Document.Unstructured; 
using Leadtools.Document.Analytics; 
 
using Leadtools.Document.Unstructured.Highlevel; 
using Leadtools.Ocr; 
using Leadtools.Document; 
 
       
async Task RunRuleSet(string ruleSetFileName, string documentFileName, IOcrEngine ocrEngine) 
{ 
   var json = LoadJson(ruleSetFileName); 
   var features = FeatureResourceBuilder.BuildFromArray(json); 
 
   var doc = LoadDocument(documentFileName); 
   doc.Text.OcrEngine = ocrEngine; 
   doc.Text.ImagesRecognitionMode = DocumentTextImagesRecognitionMode.Auto; 
   doc.Text.TextExtractionMode = DocumentTextExtractionMode.Auto; 
 
   var results = await new FeaturesProcessingEngine().Run(features.ToList(), doc, 1, 1, CancellationToken.None); 
 
   foreach (var result in results) 
   { 
      var items = result?.Items; 
      foreach (var item in items) 
      { 
         var name = item?.ElementName; 
         var val = item?.Value; 
      } 
   } 
 
   string LoadJson(string pathName) 
   { 
      var txt = File.ReadAllText(pathName); 
      var obj = JObject.Parse(txt); 
      var meta = obj["meta"]; 
      if (null == meta) 
      { 
         throw new Exception("Couldn't find the meta info in the ruleset file, make sure this file was saved using this demo."); 
      } 
      return meta.ToString(); 
   } 
 
   LEADDocument LoadDocument(string pathName) 
   { 
      var options = new LoadDocumentOptions() 
      { 
         FirstPageNumber = 1, 
         LastPageNumber = -1, 
         TimeoutMilliseconds = 0, 
         MaximumImagePixelSize = 12288 
      }; 
 
      return DocumentFactory.LoadFromFile(pathName, options); 
   } 
} 
Requirements

Target Platforms

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Unstructured Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.