import re


def make_title_site_similarity_function(site):
    """Curry the title_site_similarity function to only require a title."""
    def remove_non_alphanumerics(word):
        """Returns the `word` with nonalphanumerics (and underscores)."""
        return re.sub(r'[^\w]', '', word)

    def title_site_similarity(title_part):
        """What portion of the words in the title part are in the site?

        Don't count very common words like "the" towards the score.
        http://www.world-english.org/english500.htm

        """
        common_words = ['the', 'of', 'to', 'and', 'a', 'in', 'is', 'it']
        result = 0.0
        words = re.split(r'[. ]', title_part)
        words = [word for word in words if word not in common_words]
        for word in words:
            word = word.lower()
            word = remove_non_alphanumerics(word)
            if word and word in site:
                result += 1.0 / len(words)

        return result

    return title_site_similarity