Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # prompt the user with "Enter Search Term: " and collect their input
- searchterm = input('Enter Search Term: ')
- # list of relevant search results
- matches = []
- # for each document, calculate its relevance to the search term
- for i in range(len(index)):
- relation = v.relation(v.concordance(searchterm.lower()), index[i])
- if relation != 0:
- matches.append((relation, documents[i][:100]))
- # sort matches in descending order (most relevant first)
- matches.sort(reverse=True)
- for i in matches:
- print (i[0],i[1])
Advertisement
Add Comment
Please, Sign In to add comment