function [one21_score, one21CL_tag, tag_breakdown, lab_breakdown] = one2one_map_all(conf_matrix) % computes score using greedy One-To-One map % Maps all labels even if they are redundant and contribute 0 accuracy. % If you use this code, please cite: % Michael Lamar*, Yariv Maron*, Mark Johnson, Elie Bienenstock. % SVD and clustering for unsupervised POS tagging. (ACL 2010) % For more information, see the above reference. [r,c] = size(conf_matrix); % r is the number of tags in the tagset, c is the number of labels one21CL_tag=zeros(1,c); % store the tag for each of the c labels one21_score = 0; % initialize the score map = zeros(r,c); % store map in matrix form conf_mat = conf_matrix; for i = 1:min(r,c); % iterate until we run out of tags or labels [a,b] = max(conf_mat(:)); % find the biggest entry [rr,cc] = ind2sub(size(conf_mat),b); % find the corresponding tag and label one21CL_tag(cc) = rr; % store the tag that goes with the label % but leave it at 0 if label is not used map(rr, cc) = 1; % update map conf_mat(rr,:) = NaN; % remove the row conf_mat(:,cc) = NaN; % and the column one21_score = one21_score + a; % bump up the score end tag_breakdown = sum(conf_matrix.*map, 2); % breakdown of score according to tags lab_breakdown = sum(conf_matrix.*map, 1); % breakdown of score according to labels