Relevancy - incorporate the position at which matches occur.

Hi @philc.  My git foo being weak, this is a continuation of #722.  See that thread for motivation and discussion.

I've incorporated your suggestions from the other thread, and tidied up the comments.