Tesseract  3.02
tesseract-ocr/ccstruct/matrix.cpp
Go to the documentation of this file.
00001 /* -*-C-*-
00002  ********************************************************************************
00003  *
00004  * File:        matrix.c  (Formerly matrix.c)
00005  * Description:  Ratings matrix code. (Used by associator)
00006  * Author:       Mark Seaman, OCR Technology
00007  * Created:      Wed May 16 13:18:47 1990
00008  * Modified:     Wed Mar 20 09:44:47 1991 (Mark Seaman) marks@hpgrlt
00009  * Language:     C
00010  * Package:      N/A
00011  * Status:       Experimental (Do Not Distribute)
00012  *
00013  * (c) Copyright 1990, Hewlett-Packard Company.
00014  ** Licensed under the Apache License, Version 2.0 (the "License");
00015  ** you may not use this file except in compliance with the License.
00016  ** You may obtain a copy of the License at
00017  ** http://www.apache.org/licenses/LICENSE-2.0
00018  ** Unless required by applicable law or agreed to in writing, software
00019  ** distributed under the License is distributed on an "AS IS" BASIS,
00020  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00021  ** See the License for the specific language governing permissions and
00022  ** limitations under the License.
00023  *
00024  *********************************************************************************/
00025 /*----------------------------------------------------------------------
00026               I n c l u d e s
00027 ----------------------------------------------------------------------*/
00028 #include "matrix.h"
00029 
00030 #include "callcpp.h"
00031 #include "ratngs.h"
00032 #include "tprintf.h"
00033 #include "unicharset.h"
00034 
00035 // Print the best guesses out of the match rating matrix.
00036 void MATRIX::print(const UNICHARSET &unicharset) const {
00037   tprintf("Ratings Matrix (top choices)\n");
00038   int row, col;
00039   for (col = 0; col < this->dimension(); ++col) tprintf("\t%d", col);
00040   tprintf("\n");
00041   for (row = 0; row < this->dimension(); ++row) {
00042     for (col = 0; col <= row; ++col) {
00043       if (col == 0) tprintf("%d\t", row);
00044       BLOB_CHOICE_LIST *rating = this->get(col, row);
00045       if (rating != NOT_CLASSIFIED) {
00046         BLOB_CHOICE_IT b_it(rating);
00047         int counter = 0;
00048         for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
00049           tprintf("%s ", unicharset.id_to_unichar(b_it.data()->unichar_id()));
00050           ++counter;
00051           if (counter == 3) break;
00052         }
00053         tprintf("\t");
00054       } else {
00055         tprintf(" \t");
00056       }
00057     }
00058     tprintf("\n");
00059   }
00060 }