Moved ranking to list comprehensions and using heapq

There are two main changes in this PR. The first is to move the loops into list comprehensions through the use of two new functions: filename_score and path_score (a minor change to make that a little tidier was that line that do not match the pattern are given a score of zero). The second major change is to use the heapq library to find the best scores so that less sorting needs to be performed.