【问题标题】:"language_model_penalty_non_dict_word" has no effect in tesseract 3.01“language_model_penalty_non_dict_word”在 tesseract 3.01 中无效
【发布时间】:2015-04-23 14:32:46
【问题描述】:
我正在通过 Tesseract 3.01 的配置文件设置 language_model_penalty_non_dict_word,但它的值没有任何效果。我尝试过使用多个图像和多个值,但每个图像的输出总是相同的。另一位用户注意到了相同的in a comment in another question。
编辑:查看源代码后,变量language_model_penalty_non_dict_word仅在函数float LanguageModel::ComputeAdjustedPathCost内部使用。
但是,这个函数永远不会被调用!它仅被 2 个函数引用 - LanguageModel::UpdateBestChoice() 和 LanguageModel::AddViterbiStateEntry()。我在这些函数中放置了断点,但它们也没有被调用。
【问题讨论】:
标签:
command-line
ocr
tesseract
【解决方案1】:
经过一番调试,我终于找到了原因——函数Wordrec::SegSearch()没有被调用(它在LanguageModel::ComputeAdjustedPathCost()的调用图中)。
从此代码:
if (enable_new_segsearch) {
SegSearch(&chunks_record, word->best_choice,
best_char_choices, word->raw_choice, state);
} else {
best_first_search(&chunks_record, best_char_choices, word,
state, fixpt, best_state);
}
所以你需要在配置文件中设置enable_new_segsearch:
enable_new_segsearch 1
language_model_penalty_non_freq_dict_word 0.2
language_model_penalty_non_dict_word 0.3