mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-24 02:59:07 +08:00
max.markin's patch for issue 345
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@477 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
653abd94b2
commit
9c53d54fe3
@ -87,3 +87,14 @@ FILE *open_file(const char *filename, const char *mode) {
|
||||
}
|
||||
return (thisfile);
|
||||
}
|
||||
|
||||
/// Check whether the file exists
|
||||
bool exists_file(const char *filename) {
|
||||
bool exists = false;
|
||||
FILE *f = NULL;
|
||||
if ((f = fopen(filename, "r")) != NULL) {
|
||||
fclose(f);
|
||||
exists = true;
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
|
@ -120,6 +120,8 @@ long long_rand(long limit);
|
||||
|
||||
FILE *open_file(const char *filename, const char *mode);
|
||||
|
||||
bool exists_file(const char *filename);
|
||||
|
||||
/* util.c
|
||||
long long_rand
|
||||
_ARGS ((long limit));
|
||||
|
@ -292,15 +292,17 @@ void Dict::init_permute() {
|
||||
DAWG_TYPE_NUMBER, lang, NUMBER_PERM);
|
||||
}
|
||||
if (((STRING &)global_user_words_suffix).length() > 0) {
|
||||
Trie *trie_ptr = new Trie(DAWG_TYPE_WORD, lang, USER_DAWG_PERM,
|
||||
MAX_USER_EDGES, getUnicharset().size());
|
||||
name = getImage()->getCCUtil()->language_data_path_prefix;
|
||||
name += global_user_words_suffix;
|
||||
if (!trie_ptr->read_word_list(name.string(), getUnicharset())) {
|
||||
tprintf("Error: failed to load %s\n", name.string());
|
||||
exit(1);
|
||||
if (exists_file(name.string())) {
|
||||
Trie *trie_ptr = new Trie(DAWG_TYPE_WORD, lang, USER_DAWG_PERM,
|
||||
MAX_USER_EDGES, getUnicharset().size());
|
||||
if (!trie_ptr->read_word_list(name.string(), getUnicharset())) {
|
||||
tprintf("Error: failed to load %s\n", name.string());
|
||||
exit(1);
|
||||
}
|
||||
dawgs_ += trie_ptr;
|
||||
}
|
||||
dawgs_ += trie_ptr;
|
||||
}
|
||||
document_words_ = new Trie(DAWG_TYPE_WORD, lang, DOC_DAWG_PERM,
|
||||
MAX_DOC_EDGES, getUnicharset().size());
|
||||
|
Loading…
Reference in New Issue
Block a user