コード例 #1
0
 def test_fill_items(self):
     user_dict = {
             'fulano': {},
             'sicrano': {},
             'beltrano': {},
             'escher': {},
             'bach': {},
             'bartok': {}}
     expected = {
             'fulano': {
                 'theonlinephotographer.com': 1.0,
                 'joelonsoftware.com': 1.0,
                 'django.org': 1.0,
                 'codecomplete.com': 1.0,
                 'news.ycombinator.com': 1.0,
                 'python.org': 1.0,
                 'publico.pt': 0.0,
                 'nyt.com': 0.0,
                 'dn.pt': 0.0},
             'sicrano': {
                 'codecomplete.com': 1.0,
                 'django.org': 1.0,
                 'dn.pt': 0.0,
                 'joelonsoftware.com': 1.0,
                 'news.ycombinator.com': 1.0,
                 'nyt.com': 1.0,
                 'publico.pt': 1.0,
                 'python.org': 1.0,
                 'theonlinephotographer.com': 1.0},
             'beltrano': {
                 'codecomplete.com': 1.0,
                 'django.org': 0.0,
                 'dn.pt': 1.0,
                 'joelonsoftware.com': 1.0,
                 'news.ycombinator.com': 1.0,
                 'nyt.com': 1.0,
                 'publico.pt': 1.0,
                 'python.org': 1.0,
                 'theonlinephotographer.com': 0.0},
             'escher': {
                 'codecomplete.com': 0.0,
                 'django.org': 0.0,
                 'dn.pt': 0.0,
                 'joelonsoftware.com': 0.0,
                 'news.ycombinator.com': 1.0,
                 'nyt.com': 1.0,
                 'publico.pt': 1.0,
                 'python.org': 0.0,
                 'theonlinephotographer.com': 0.0},
             'bach': {
                 'codecomplete.com': 0.0,
                 'django.org': 0.0,
                 'dn.pt': 0.0,
                 'joelonsoftware.com': 1.0,
                 'news.ycombinator.com': 1.0,
                 'nyt.com': 0.0,
                 'publico.pt': 0.0,
                 'python.org': 0.0,
                 'theonlinephotographer.com': 0.0},
             'bartok': {
                 'codecomplete.com': 1.0,
                 'django.org': 0.0,
                 'dn.pt': 0.0,
                 'joelonsoftware.com': 1.0,
                 'news.ycombinator.com': 1.0,
                 'nyt.com': 1.0,
                 'publico.pt': 0.0,
                 'python.org': 0.0,
                 'theonlinephotographer.com': 1.0}}
     actual = drec.fill_items(user_dict)
     self.assertEqual(actual, expected)
コード例 #2
0
ファイル: main.py プロジェクト: rfguri/link-recommender
# Library imports
import recommendations, deliciousrec

# Initialize delicious users
delusers=deliciousrec.initialize_user_dict('programming')
# Add myself to the dataset
delusers['rogerfernandezg']={}
# Fills delicious users with data from delicious
deliciousrec.fill_items(delusers)
# Show recommendations for specific user
user=delusers.keys()[1]
print recommendations.top_matches(delusers,user)[0:10]
url=recommendations.get_recommendations(delusers,user)[0][1]
print recommendations.top_matches(recommendations.transform_prefs(delusers),url)