move similarity calculations to isolated functions

this isn't working yet… at runtime, it segfaults trying to call the
similarity functions.