←Select platform

WordIsCertain Property

Summary
Gets or sets a value indicating whether the word this character is part of has passed spell checking.
Syntax
C#
Objective-C
C++/CLI
Java
publicboolWordIsCertain {get;set; }
@property (nonatomic, assign) BOOL wordIsCertain;
publicbooleangetWordIsCertain()publicvoidsetWordIsCertain(booleanvalue)
public:propertyboolWordIsCertain {boolget();voidset (bool);}

Property Value

Trueif the word this character is part of has passed spell checking; otherwise it isfalse.

Remarks

The word is certain if it passes one of the following criteria:

  1. The engine is very confident of the letters of the word, even if the word is not in the dictionary
  2. The engine is not very confident, but the word is in the dictionary

To get the recognized characters of a page, callIOcrPage.GetRecognizedCharactersafterIOcrPage.Recognize.

To update the recognized characters of a page, callIOcrPage.GetRecognizedCharactersbefore callingIOcrDocument.SaveorIOcrDocument.SaveXml.

Example
C#
usingLeadtools;usingLeadtools.Codecs;usingLeadtools.Ocr;usingLeadtools.Forms.Common;usingLeadtools.Document.Writer;usingLeadtools.WinForms;usingLeadtools.Drawing;usingLeadtools.ImageProcessing;usingLeadtools.ImageProcessing.Color;publicvoidRecognizedCharactersExample(){// Create an image with some text in itRasterImage image =newRasterImage(RasterMemoryFlags.Conventional, 640, 200, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft,null, IntPtr.Zero, 0);Rectangle imageRect =newRectangle(0, 0, image.ImageWidth, image.ImageHeight);IntPtr hdc = RasterImagePainter.CreateLeadDC(image);using(Graphics g = Graphics.FromHdc(hdc)){g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;g.FillRectangle(Brushes.White, imageRect);using(Font f =newFont("Arial", 20, FontStyle.Regular))g.DrawString("Normal line", f, Brushes.Black, 0, 0);using(Font f =newFont("Arial", 20, FontStyle.Bold))g.DrawString(“粗体,斜体underline", f, Brushes.Black, 0, 40);using(Font f =newFont("Courier New", 20, FontStyle.Regular))g.DrawString("Monospaced line", f, Brushes.Black, 0, 80);}RasterImagePainter.DeleteLeadDC(hdc);stringtextFileName = Path.Combine(LEAD_VARS.ImagesDir,"MyImageWithTest.txt");stringpdfFileName = Path.Combine(LEAD_VARS.ImagesDir,"MyImageWithTest.pdf");// Create an instance of the engineusing(IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)){// Start the engine using default parametersocrEngine。Startup(null,null,null, LEAD_VARS.OcrLEADRuntimeDir);// Create an OCR pageIOcrPage ocrPage = ocrEngine.CreatePage(image, OcrImageSharingMode.AutoDispose);// Recognize this pageocrPage.Recognize(null);// Dump the characters into a text fileusing(StreamWriter writer = File.CreateText(textFileName)){IOcrPageCharacters ocrPageCharacters = ocrPage.GetRecognizedCharacters();foreach(IOcrZoneCharacters ocrZoneCharactersinocrPageCharacters){// Show the words found in this zone. Get the word boundaries in inchesICollection words = ocrZoneCharacters.GetWords();Console.WriteLine("Words:");foreach(OcrWord wordinwords)Console.WriteLine("Word: {0}, at {1}, characters index from {2} to {3}", word.Value, word.Bounds, word.FirstCharacterIndex, word.LastCharacterIndex);boolnextCharacterIsNewWord =true;for(inti = 0; i < ocrZoneCharacters.Count; i++){OcrCharacter ocrCharacter = ocrZoneCharacters[i];// Capitalize the first letter if this is a new wordif(nextCharacterIsNewWord)ocrCharacter.Code = Char.ToUpper(ocrCharacter.Code);writer.WriteLine("Code: {0}, Confidence: {1}, WordIsCertain: {2}, Bounds: {3}, Position: {4}, FontSize: {5}, FontStyle: {6}",ocrCharacter.Code,ocrCharacter.Confidence,ocrCharacter.WordIsCertain,ocrCharacter.Bounds,ocrCharacter.Position,ocrCharacter.FontSize,ocrCharacter.FontStyle);// If the character is bold, make it underlineif((ocrCharacter.FontStyle & OcrCharacterFontStyle.Bold) == OcrCharacterFontStyle.Bold){ocrCharacter.FontStyle |= OcrCharacterFontStyle.Italic;ocrCharacter.FontStyle |= OcrCharacterFontStyle.Underline;}// Check if next character is the start of a new wordif((ocrCharacter.Position & OcrCharacterPosition.EndOfWord) == OcrCharacterPosition.EndOfWord ||(ocrCharacter.Position & OcrCharacterPosition.EndOfLine) == OcrCharacterPosition.EndOfLine)nextCharacterIsNewWord =true;elsenextCharacterIsNewWord =false;ocrZoneCharacters[i] = ocrCharacter;}}// Replace the characters with the modified one before we saveocrPage.SetRecognizedCharacters(ocrPageCharacters);}// Create an OCR document so we can save the resultsusing(IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument(null, OcrCreateDocumentOptions.AutoDeleteFile)){// Add the page and dispose itocrDocument.Pages.Add(ocrPage);ocrPage.Dispose();// Show the recognition results// Set the PDF options to save as PDF/A text onlyPdfDocumentOptions pdfOptions = ocrEngine.DocumentWriterInstance.GetOptions(DocumentFormat.Pdf)asPdfDocumentOptions;pdfOptions.DocumentType = PdfDocumentType.PdfA;pdfOptions.ImageOverText =false;ocrEngine。DocumentWriterInstance.SetOptions(DocumentFormat.Pdf, pdfOptions);ocrDocument.Save(pdfFileName, DocumentFormat.Pdf,null);// Open and check the result file, it should contain the following text// "Normal Line"// "Bold And Italic Line"// "Monospaced Line"// With the second line bold and underlined now}// Shutdown the engine// Note: calling Dispose will also automatically shutdown the engine if it has been startedocrEngine。Shutdown();}}staticclassLEAD_VARS{publicconststringImagesDir =@"C:\LEADTOOLS22\Resources\Images";publicconststringOcrLEADRuntimeDir =@"C:\LEADTOOLS22\Bin\Common\OcrLEADRuntime";}
Requirements

Target Platforms

Leadtools.Ocr Assembly
188金宝搏的网址客服|Support|Contact Us|Intellectual Property Notices
© 1991-2023LEAD Technologies, Inc.All Rights Reserved.