Document Distance algorithm implementation in java