about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/pretty_print_hhmm_parse.m
blob: 81b965d5367962fb964456dd84a8c684bd7efbb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function pretty_print_hhmm_parse(mpe, Qnodes, Fnodes, Onode, alphabet)
% function pretty_print_hhmm_parse(mpe, Qnodes, Fnodes, Onode, alphabet)
%
% mpe(i,t) is the most probable value of node i at time t
% Qnodes(1:D), Fnodes = [F2 .. FD], Onode contain the node ids
% alphabet(i) is the i'th output symbol, or [] if don't want displayed

T = size(mpe,2);
ncols = 20;
t1 = 1; t2 = min(T, t1+ncols-1);
while (t1 < T)
  %fprintf('%d:%d\n', t1, t2);
  if iscell(mpe)
    print_block_cell(mpe(:,t1:t2), Qnodes, Fnodes, Onode, alphabet, t1);
  else
    print_block(mpe(:,t1:t2), Qnodes, Fnodes, Onode, alphabet, t1);
  end
  fprintf('\n\n');
  t1 = t2+1; t2 = min(T, t1+ncols-1);
end

%%%%%%

function print_block_cell(mpe, Qnodes, Fnodes, Onode, alphabet, start)

D = length(Qnodes);
T = size(mpe, 2);
fprintf('%3d ', start:start+T-1); fprintf('\n');
for d=1:D
  for t=1:T
    if (d > 1) & (mpe{Fnodes(d-1),t} == 2)
      fprintf('%3d|', mpe{Qnodes(d), t});
    else
      fprintf('%3d ', mpe{Qnodes(d), t});
    end
  end
  fprintf('\n');
end
if ~isempty(alphabet)
  a = cell2num(mpe(Onode,:));
  %fprintf('%3c ', alphabet(mpe{Onode,:}));
  fprintf('%3c ', alphabet(a))
  fprintf('\n');
end


%%%%%%

function print_block(mpe, Qnodes, Fnodes, Onode, alphabet, start)

D = length(Qnodes);
T = size(mpe, 2);
fprintf('%3d ', start:start+T-1); fprintf('\n');
for d=1:D
  for t=1:T
    if (d > 1) & (mpe(Fnodes(d-1),t) == 2)
      fprintf('%3d|', mpe(Qnodes(d), t));
    else
      fprintf('%3d ', mpe(Qnodes(d), t));
    end
  end
  fprintf('\n');
end
if ~isempty(alphabet)
  fprintf('%3c ', alphabet(mpe(Onode,:)));
  fprintf('\n');
end