【问题标题】:FineReader - How to create/use a custom dictionaryFineReader - 如何创建/使用自定义词典
【发布时间】:2017-03-30 17:24:51
【问题描述】:

我正在尝试创建一个自定义字典以用于 Abby FineReader SDK for C#,但没有成功。

是否有人知道如何在 FineReader 中创建和使用自定义词典?

【问题讨论】:

    标签: ocr finereader


    【解决方案1】:
    DocumentProcessingParams dpParams = engine.CreateDocumentProcessingParams();
    dpParams.PageProcessingParams.RecognizerParams.TextLanguage = makeTextLanguage("DICTIONARY PATH");   
    
    private TextLanguage makeTextLanguage(string dictionaryPath)
    {
        // Create new TextLanguage object
        LanguageDatabase languageDatabase = engine.CreateLanguageDatabase();
        TextLanguage textLanguage = languageDatabase.CreateTextLanguage();
        var textlanguageName = Path.GetFileName(new FileInfo(textBox_dictionary.Text).Name);
    
        // Copy all attributes from predefined English language
        TextLanguage tempL = engine.PredefinedLanguages.Find("PortugueseBrazilian")
            .TextLanguage;
        textLanguage.CopyFrom(tempL);
        textLanguage.InternalName = textlanguageName;
    
        // Bind new dictionary to first (and single) BaseLanguage object within TextLanguage
        BaseLanguage baseLanguage = textLanguage.BaseLanguages[0];
    
        // Change internal dictionary name to user-defined
        baseLanguage.InternalName = textlanguageName;
    
        //set custom doctionary for base language
        setDictionary(baseLanguage, dictionaryPath);
    
        return textLanguage;
    }
    
    //set custom dictinary for base language
    private void setDictionary(BaseLanguage baseLanguage, string dictionaryPath)
    {
        //create dictionary file
    
        // Get collection of dictionary descriptions and remove all items
        DictionaryDescriptions dictionaryDescriptions = baseLanguage.DictionaryDescriptions;
        //dictionaryDescriptions.DeleteAll();
    
        // Create user dictionary description and add it to the collection
        IDictionaryDescription dictionaryDescription = dictionaryDescriptions.AddNew(DictionaryTypeEnum.DT_UserDictionary);
        UserDictionaryDescription userDictionaryDescription = dictionaryDescription.GetAsUserDictionaryDescription();
    
        userDictionaryDescription.FileName = dictionaryPath;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-07
      • 2014-11-11
      • 2018-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多