chiark / gitweb /
fix space handling
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Thu, 4 Jun 2009 19:25:01 +0000 (20:25 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Thu, 4 Jun 2009 19:25:01 +0000 (20:25 +0100)
pctb/convert.c
pctb/database
pctb/ocr.c

index c8082e697cea3ff4f70b26c1e1d24c9e72e2eafc..163f81448882a632980e5a6b6db1db7a778607a1 100644 (file)
@@ -257,7 +257,7 @@ static void ocr_rectangle(Rect r) {
 
   results= ocr(w,h,cols);
   printf("YES! \"");
-  for (res=0; res->s; res++)
+  for (res=results; res->s; res++)
     printf("%s",res->s);
   printf("\"\n");
   eassert(!ferror(stdout));
index 65c84ffe039f3c0b686480b7ee19f6af04f50df8..847b618bd5d17e407637e3f03b42c95cae1c86f5 100644 (file)
@@ -1,3 +1,11 @@
+0 1 61
+6
+640
+920
+920
+920
+fc0
+800
 0 1 67
 5
 27c0
@@ -5,6 +13,12 @@
 2820
 2420
 1fe0
+0 1 72
+4
+fe0
+40
+20
+20
 0 1 75
 5
 7e0
@@ -20,37 +34,3 @@ fe0
 888
 708
 8
-1 1 61
-6
-640
-920
-920
-920
-fc0
-800
-1 1 63
-4
-7c0
-820
-820
-820
-1 1 65
-5
-7c0
-920
-920
-920
-9c0
-1 1 6e
-5
-fe0
-40
-20
-20
-fc0
-1 1 72
-4
-fe0
-40
-20
-20
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;