chiark / gitweb /
fix space handling
[ypp-sc-tools.main.git] / pctb / ocr.c
index df4aacfbb05e299e09642f66115abfbe0bd8b584..be479f83b8d626442899c77f08ffdab049e26747 100644 (file)
@@ -121,6 +121,7 @@ static void callout_unknown(int w, int h, Pixcol cols[],
   }
   fprintf(resolver,"%d %d %d",unk_l,unk_r,unk_ctx);
   for (i=0, s=sofar; i<nsofar; i++, s++) {
+    if (!strcmp(s->s," ")) continue;
     fprintf(resolver," %d %d %d ",s->l,s->r,s->ctx);
     for (p=s->s; (c= *p); p++) {
       if (c=='\\') fprintf(resolver,"\\%c",c);
@@ -198,7 +199,7 @@ static void add_result(const char *s, int l, int r, int ctx) {
 }
 
 OcrResultGlyph *ocr(int w, int h, Pixcol cols[]) {
-  int nspaces=0;
+  int nspaces=-w;
   int ctx=1,i, x;
 
   nresults=0;
@@ -220,9 +221,14 @@ OcrResultGlyph *ocr(int w, int h, Pixcol cols[]) {
     if (!cols[x]) {
       nspaces++;
       x++;
-      if (nspaces>3) ctx=1;
+      if (nspaces==3) {
+       fprintf(debug,"OCR  x=%x nspaces=%d space\n",x,nspaces);
+       add_result(" ",x-nspaces,x+1,0);
+       ctx=1;
+      }
       continue;
     }
+    nspaces=0;
 
     /* find character */
     OCRDatabaseNode *current=0, *bestmatch=0;