If you're looking for a way to find similarity between strings, this SO question suggests Levenshtein distance as a method of doing so.
There is a solution ready, and it also exists in the Natural Language Tool Kit library.
The naive integration would be (I use random merely to have a result. It doesn't make sense obviously):
#!/usr/bin/env python
query = ["football", "basketball", "martial arts", "baseball"]
lists = [["apple", "football", "basketball court"], ["ball"], ["martial-arts", "baseball", "banana", "food", "doctor"]]
from random import random
def fake_levenshtein(word1, word2):
return random()
def avg_list(l):
return reduce(lambda x, y: x + y, l) / len(l)
for l in lists:
score = []
for w1 in l:
for w2 in query:
score.append(fake_levenshtein(w1, w2))
print avg_list(score)
Good luck.