typedef struct DatabaseNode {
char s[MAXGLYPHCHRS+1]; /* null-terminated; "" means no match here */
int nlinks, alinks;
+ unsigned endsword:1;
DatabaseLink *links;
} DatabaseNode;
char chrs[MAXGLYPHCHRS+1];
Pixcol cv;
int r,j,ctxi;
- int h;
+ int h, endsword;
char lbuf[100];
FILE *db;
}
chrs[nchrs++]= c;
}
+ endsword= 0;
+ if (nchrs>1 && chrs[nchrs-1]==' ') {
+ endsword= 1;
+ nchrs--;
+ }
chrs[nchrs]= 0;
current= &rd->contexts[ctxi];
eassert(!current->s[0]);
strcpy(current->s, chrs);
+ current->endsword= endsword;
}
eassert(!ferror(db));
eassert(!fclose(db));
found:
current= current->links[i].then;
if (current->s[0]) {
- debugf(" \"%s\"",current->s);
+ debugf(" \"%s\"%s",current->s,current->endsword?"_":"");
bestmatch= current;
bestmatch_rx= x;
} else {
}
if (uniquematch) {
- debugf(" || YES\n");
+ debugf(" || YES");
add_result(rd, uniquematch->s, lx, uniquematch_rx, ctxmap);
x= uniquematch_rx+1;
- ctxmap= ct->midword;
+ if (uniquematch->s[0]) ctxmap= ct->midword;
+ else debugf(" (empty)");
+ if (uniquematch->endsword) {
+ nspaces= SPACE_SPACES;
+ debugf("_");
+ ctxmap= ct->nextword;
+ }
+ debugf("\n");
} else {
int rx;
debugf(" || UNKNOWN");