In below we give the code of lsi on matlab.
function sim = lsi_calc(A,q,k)
[m,n] = size(A);
[U,S,V] = svds(A,k);
qc = q'*U*inv(S);
for i = 1:n % Loop over all documents
sim(i) = (qc * V(i,:)') / (norm(qc) * norm(V(i,:)));
end;
No comments:
Post a Comment