in reply to Converting tesseract box data into 2d grid
Update:BTW, there is an error in your data compared to the image; the R at the start of the middle line has come out as an I.
Inverting the table left as an exercise, as is programmaticly deriving the magic numbers :):
#! perl -slw use strict; use Data::Dump qw[ pp ]; $Data::Dump::WIDTH = 200; use List::Util qw[ min ]; my %pos; while( <DATA> ) { my( $c, $x1, $y1, $x2, $y2 ) = split ' '; $pos{ int( $y1 / 12 ) }{ int( $x1 / 10.5 ) } = $c; } my $firstY = min( keys %pos ); my @firstXs = sort{ $a <=> $b } keys %{ $pos{ $firstY } }; for my $y ( grep $_ != $firstY, keys %pos ) { $pos{ $y }{ $_ } //= ' ' for @firstXs; } pp \%pos; __DATA__ ... from the OP
Output:
C:\test>1114833 { 1 => { 1 => "T", 4 => "S", 6 => "E", 9 => "C", 11 => "I", 13 => "E", + 16 => "N", 18 => "E", 20 => "O", 23 => "T", 25 => "Y", 28 => "U", 30 + => "E" }, 3 => { 1 => " ", 4 => "I", 6 => "I", 9 => "L", 11 => "V", 13 => "E", + 16 => "V", 18 => "N", 20 => "U", 23 => "Y", 25 => "Z", 28 => "L", 30 + => " " }, 5 => { 1 => " ", 4 => "I", 6 => "O", 9 => "L", 11 => "I", 13 => "E", + 16 => "D", 18 => "P", 20 => "B", 23 => "H", 25 => "O", 28 => "S", 30 + => " " }, 7 => { 1 => " ", 4 => "B", 6 => "I", 9 => "C", 11 => "C", 13 => "Y", + 16 => "D", 18 => "I", 20 => "T", 23 => "Z", 25 => "I", 28 => " ", 30 + => " " }, 9 => { 1 => " ", 4 => " ", 6 => "N", 9 => " ", 11 => "K", 13 => "A", + 16 => " ", 18 => " ", 20 => " ", 23 => "L", 25 => " ", 28 => " ", 30 + => " " }, }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Converting tesseract box data into 2d grid
by Anonymous Monk on Jan 29, 2015 at 00:47 UTC | |
by BrowserUk (Patriarch) on Jan 29, 2015 at 01:27 UTC | |
|
Re^2: Converting tesseract box data into 2d grid
by Anonymous Monk on Jan 29, 2015 at 00:49 UTC |