首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FineReader -如何创建/使用自定义字典

FineReader -如何创建/使用自定义字典
EN

Stack Overflow用户
提问于 2017-03-31 01:24:52
回答 1查看 486关注 0票数 1

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

有没有人知道如何在FineReader中创建和使用自定义字典?

EN

回答 1

Stack Overflow用户

发布于 2017-04-18 20:54:45

代码语言:javascript
复制
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;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43124545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档