#!/usr/bin/perl use warnings; use strict; use lib 'lib'; use Conclave::Mapper::Mapping; use File::Slurp qw/write_file read_file/; use Data::Dumper; use HTML::Auto qw/matrix/; use File::Basename; our $HOME = '/home/smash/conclave-website-root'; my $pkgid = 'tree-1.5.3'; my $mapper = Conclave::Mapper::Mapping->new($pkgid); my $q1 = shift || "[ onto=program class=Function ]"; my $q2 = shift || "[ onto=problem class=Concept ]"; my $f = shift || 'kpss'; my $map = $mapper->map($q1, $q2, $f); print Dumper $map->rank; #print Dumper $map; __END__ my (%cols, %rows); foreach (@{ $map->cells }) { $cols{$_->col}++; $rows{$_->row}++; } my @cols = sort keys %cols; my @lines = sort keys %rows; my $data; foreach my $i (@lines) { my @line; foreach my $j (@cols) { my $cell = get_cell($j, $i); push @line, $cell?sprintf("%.2f",get_color($cell->score),$cell->score) : '-'; } push @$data, [@line]; } @cols = map {basename($_)} @cols; @lines = map {basename($_)} @lines; print matrix(\@cols, \@lines, $data); sub get_cell { my ($c, $r) = @_; foreach (@{ $map->cells }) { return $_ if ( ($c eq $_->col) and ($r eq $_->row) ); } return undef; } sub get_color { my $s = shift; return 'green' if ($s <= 2); return 'orange' if ($s <= 6); return 'red'; }