1

I'm trying to create a custom dictionary to use into Abby FineReader SDK for C#, but I'm getting no success.

Is there someone who knows how to create and use a custom dictionary into FineReader?

Grandpa
  • 63
  • 8

1 Answers1

0
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;
}
Grandpa
  • 63
  • 8