chiark / gitweb /
fix space handling
[ypp-sc-tools.main.git] / pctb / ocr.c
index 7f3be26a0eaee8c90906129c674d56514d74ad54..be479f83b8d626442899c77f08ffdab049e26747 100644 (file)
@@ -110,7 +110,8 @@ static void callout_unknown(int w, int h, Pixcol cols[],
       /* we know donepipe[1] is >= 4 and we have dealt with all the others
        * so we aren't in any danger of overwriting some other fd 4: */
       r= dup2(donepipe[1],4); eassert(r==4);
-      execlp("./show-thing.tcl", "./show-thing.tcl","--automatic",(char*)0);
+      execlp("./show-thing.tcl", "./show-thing.tcl",
+            "--automatic","1",(char*)0);
       eassert(!"execlp failed");
     }
     r= close(jobpipe[0]); eassert(!r);
@@ -120,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);
@@ -197,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;
@@ -219,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;