当前位置: 首页>>代码示例>>C#>>正文


C# IEngine.CreateCharParams方法代码示例

本文整理汇总了C#中IEngine.CreateCharParams方法的典型用法代码示例。如果您正苦于以下问题:C# IEngine.CreateCharParams方法的具体用法?C# IEngine.CreateCharParams怎么用?C# IEngine.CreateCharParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEngine的用法示例。


在下文中一共展示了IEngine.CreateCharParams方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Using_recognition_variants_and_extended_character_info

        // USE CASE: Using recognition variants and extended character info
        public static void Using_recognition_variants_and_extended_character_info( IEngine engine )
        {
            trace( "Enable recognition variants..." );
            engine.EnableRecognitionVariants( true );

            trace( "Prepare a sample document..." );
            IDocument document = PrepareNewRecognizedDocument( engine );

            trace( "Find the field of interest..." );
            IField field = findField( document, "InvoiceNumber" );
            assert( field != null );

            traceBegin( "Show word variants..." );
            // (1) You might want to use word variants if you know how to choose the correct result
            // and this knowledge cannot be communicated to the engine (in the form of a regular expression
            // or dictionary) or if you decide that you can do the selection better.
            // EXAMPLES: (1) a field containing some code with a checksum (2) a field that can be looked up
            // in a database (3) a field that can be crosschecked with another field in the same document
            IText text = field.Value.AsText;
            assert( text.RecognizedWordsCount == 1 );
            IRecognizedWordInfo wordInfo = engine.CreateRecognizedWordInfo();
            // Get the recognition info for the first word. Thus we'll know the number of available variants
            text.GetRecognizedWord( 0, -1, wordInfo );
            for( int i = 0; i < wordInfo.RecognitionVariantsCount; i++ ) {
                // Get the specified recognition variant for the word
                text.GetRecognizedWord( 0, i, wordInfo );
                trace( wordInfo.Text );
            }
            traceEnd( "" );

            traceBegin( "Show char variants for each word variant..." );
            // (2) You can use a more advanced approach and build your own hypotheses from variants
            // for individual characters. This approach can be very computationally intensive, so use it with care.
            // Use word/char variant confidence to limit the number of built hypotheses
            IRecognizedCharacterInfo charInfo = engine.CreateRecognizedCharacterInfo();
            for( int k = 0; k < wordInfo.RecognitionVariantsCount; k ++ ) {
                // For each variant of the first word
                text.GetRecognizedWord( 0, k, wordInfo );
                traceBegin( wordInfo.Text );
                for( int i = 0; i < wordInfo.Text.Length; i++ ) {
                    // Get the recognition info for the first character (the number of available variants)
                    wordInfo.GetRecognizedCharacter( i, -1, charInfo );
                    string charVars = "";
                    for( int j = 0; j < charInfo.RecognitionVariantsCount; j++ ) {
                        // Get the specified recognition variant for the character. The variant may contain
                        // more than one character if the geometry in the specified position can be interpreted
                        // as several merged characters. For example, something which looks like poorly printed 'U'
                        // can actually be a pair of merged 'I'-s or 'I' + 'J'
                        wordInfo.GetRecognizedCharacter( i, j, charInfo );
                        if( charInfo.CharConfidence > 50 ) {
                            charVars += charInfo.Character.PadRight( 4, ' ' );
                        }
                    }
                    trace( charVars );
                }
                traceEnd( "" );
            }
            traceEnd( "" );

            traceBegin( "Linking text in the field to recognition variants..." );
            // (3) You can find corresponding recognition word and character variants for each character in the text
            // even if the text has been modified. This can be helpful in building your own advanced verification tools
            // where users can choose variants for words while typing or from a list
            ICharParams charParams = engine.CreateCharParams();
            for( int i = 0; i < text.Length; i++ ) {
                text.GetCharParams( i, charParams );
                trace( string.Format( "'{0}' is char number {1} in word number {2}", text.Text[i],
                    charParams.RecognizedWordCharacterIndex, charParams.RecognizedWordIndex ) );
            }
            traceEnd( "" );

            traceBegin( "Obtaining extended char information for characters in text..." );
            // (4) You can obtain extended char info for a character in the text without getting involved deeply in
            // the recognition variants API by means of the shortcut method GetCharParamsEx
            for( int i = 0; i < text.Length; i++ ) {
                text.GetCharParamsEx( i, charParams, charInfo );
                trace( string.Format( "'{0}' serif probability is {1}", charInfo.Character, charInfo.SerifProbability ) );
            }
            traceEnd( "" );

            // Restore the initial state of the engine. It is optional and should not be done if you always
            // use recognition variants. Doing so will reset some internal caches and if done repeatedly
            // might affect performance
            engine.EnableRecognitionVariants( false );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:86,代码来源:Advanced+techniques.cs

示例2: recursiveCheckVerified

 ///////////////////////////////////////////////////////////////////////////////
 static void recursiveCheckVerified( IEngine engine, IField field )
 {
     if( field.Value != null ) {
         assert( !field.Value.NeedsVerification );
         if( field.Value.Type == FieldValueTypeEnum.FVT_Text ) {
             IText text = field.Value.AsText;
             ICharParams p = engine.CreateCharParams();
             for( int i = 0; i < text.Length; i++ ) {
                 text.GetCharParams( i, p );
                 assert( !p.NeedsVerification );
             }
         }
     }
     recursiveCheckVerified( engine, field.Instances );
     recursiveCheckVerified( engine, field.Children );
 }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:17,代码来源:Working+with+an+existing+FlexiCapture+project.cs


注:本文中的IEngine.CreateCharParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。