Added basic document distances.
Redefined distance to use the minimium between a word and a document.