function [sim] = simCounting(AintersectB, AnotB, BnotA, alpha, beta, gamma) % count common features positively and exclusive features negatively % sim = alpha*AintersectB - beta*AnotB - gamma*BnotA % Inputs: % 1. AintersectB: common features in A and B % 2. AnotB: A's exclusive features % 3. BnotA: B's exclusive features % 4. alpha, beta, gamma: constants % Outputs: % 1. sim: similarity value sumAintersectB = 0; sumAnotB = 0; sumBnotA = 0; for i= 1:length(AintersectB) if(AintersectB(i) ~= -1) sumAintersectB = sumAintersectB + 1; end if(AnotB(i) ~= -1) sumAnotB = sumAnotB + 1; end if(BnotA(i) ~= 1) sumBnotA = sumBnotA + 1; end end %sim = (alpha .* sumAintersectB) - (beta .* sumAnotB) - (gamma .* sumBnotA); sim = sumAintersectB; %% Example %% >> comm %% comm = %% 1 1 0 %% >> A %% A = %% 0 0 1 %% >> B %% B = %% 0 0 0 %% >> sim = simCounting(comm, A, B, 1, 0.5, 0.5); %% >> sim %% sim = %% 1.5000