How to create similarity measures with a few lines of code