CODE:
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Created on 2014-9-8
@author: guaguastd
@name: tf_idf_sample.py
'''
from tfIdf import tf, tf_idf, idf
# Enter in a query term from the corpus variable
QUERY_TERMS = ['mr.', 'green']
corpus = \
{'a': 'Mr. Green killed Colonel Mustard in the study with the candlestick. \
Mr. Green is not a very nice fellow.',
'b': 'Professor Plum has a green plant in his study.',
'c': "Miss Scarlett watered Professor Plum's green plant while he was away \
from his office last week."}
for (k, v) in sorted(corpus.items()):
print k, ':', v
# Score queries by calculating cumulative tf_idf score for each term in query
q