コード例 #1
0
def test_make_recommendations_multiple_networks_and_friends():
    d_pp = {"Claire Dunphy": ["a", "b", "c"], "a b Dunphy": ["yo-o"], "yo-o": ["a b Dunphy"]}
    d_pn = {}

    assert (
        a3_functions.make_recommendations("Claire Dunphy", d_pp, d_pn) == []
    ), "multiple mutual networks and multiple friends and last names"
コード例 #2
0
def test_make_recommendations_multiple_networks_and_friends():
    d_pp = {"a": ["b", "c", "d"], "q": ["b", "c"], "d": ["a", "q"], "h": ["c", "d"]}
    d_pn = {"a": ["b", "c", "d"], "q": ["b", "c"], "d": ["a", "q"], "h": ["c", "d"]}

    assert a3_functions.make_recommendations("a", d_pp, d_pn) == [
        ("q", 4),
        ("h", 4),
    ], "multiple mutual networks and multiple friends"
コード例 #3
0
def test_make_recommendations_multiple_networks_and_friends_samelnames():
    d_pp = {"a B-3-df joe": ["b", "c", "d"], "q B-3-df joe": ["b", "c"], "d": ["a", "q"], "h": ["c", "d"]}
    d_pn = {"a B-3-df joe": ["b", "c", "d"], "q B-3-df joe": ["b", "c"], "d": ["a", "q"], "h": ["c", "d"]}

    assert a3_functions.make_recommendations("a B-3-df joe", d_pp, d_pn) == [
        ("q B-3-df joe", 5),
        ("h", 4),
    ], "multiple mutual networks and multiple friends and last names"
コード例 #4
0
def test_make_recommendations_multiple_networks_and_friends():
    d_pp = {
        "Gloria Pritchett": ["Jay Pritchett", "Cameron Tucker", "Manny Delgado"],
        "Dylan D-Money": ["Haley Gwendolyn Dunphy"],
        "Haley Gwendolyn Dunphy": ["Dylan D-Money"],
    }
    d_pn = {}
    assert a3_functions.make_recommendations("Gloria Pritchett", d_pp, d_pn) == [], "Common names"
コード例 #5
0
def test_make_recommendations_multiple_friends_empty_networks():
    d_pp = {"a": ["b", "c", "d"], "q": ["b", "c"], "d": ["a", "q"], "h": ["c", "d"]}
    d_pn = {}

    assert a3_functions.make_recommendations("a", d_pp, d_pn) == [
        ("q", 2),
        ("h", 2),
    ], "multiple mutual friends and empty no mutual networks"
コード例 #6
0
def test_make_recommendations_no_mutual_friend_or_networks():
    d_pp = {"s m": [], "A g": ["F p", "A d", "T-32"], "F p": ["A g", "A d"], "Z b": ["T=32", "A D"]}
    d_pn = {
        "s m": [],
        "A g": ["milliways restaurant", "planet freepress", "hitchhikers guild"],
        "A D": ["planet freepress", "hitchhikers guild"],
    }

    assert a3_functions.make_recommendations("s m", d_pp, d_pn) == [], "No mutual friends or networks"
コード例 #7
0
def test_make_recommendations_empty_string():
    d_pp = {"s m": [], "A g": ["F p", "A d", "T-32"], "F p": ["A g", "A d"], "Z b": ["T=32", "A D"]}
    d_pn = {
        "s m": [],
        "A g": ["milliways restaurant", "planet freepress", "hitchhikers guild"],
        "A D": ["planet freepress", "hitchhikers guild"],
    }

    assert a3_functions.make_recommendations("", d_pp, d_pn) == [], "Empty String "
コード例 #8
0
def test_make_recommendations_multiple_networks_and_friends():
    d_pp = {
        'Gloria Pritchett':
        ['Jay Pritchett', 'Cameron Tucker', 'Manny Delgado'],
        'Dylan D-Money': ['Haley Gwendolyn Dunphy'],
        'Haley Gwendolyn Dunphy': ['Dylan D-Money']
    }
    d_pn = {}
    assert a3_functions.make_recommendations('Gloria Pritchett', d_pp,d_pn)== [], \
           'Common names'
コード例 #9
0
def test_make_recommendations_multiple_networks_and_friends():
    d_pp = {
        'Claire Dunphy': ['a', 'b', 'c'],
        'a b Dunphy': ['yo-o'],
        'yo-o': ['a b Dunphy']
    }
    d_pn = {}

    assert a3_functions.make_recommendations('Claire Dunphy', d_pp,d_pn) == [], \
           'multiple mutual networks and multiple friends and last names'
コード例 #10
0
def test_make_recommendations_multiple_networks():
    d_pp = {'a': [], 'q': [], 'd': [], 'h': []}
    d_pn = {
        'a': ['b', 'c', 'd'],
        'q': ['b', 'c'],
        'd': ['a', 'q'],
        'h': ['c', 'd']
    }

    assert a3_functions.make_recommendations('a', d_pp,d_pn) == [('q',2),('h',2)], \
           'multiple mutual networks and no mutual friends'
コード例 #11
0
def test_make_recommendations_multiple_networks_and_friends_samelnames():
    d_pp = {
        'a B-3-df joe': ['b', 'c', 'd'],
        'q B-3-df joe': ['b', 'c'],
        'd': ['a', 'q'],
        'h': ['c', 'd']
    }
    d_pn = {
        'a B-3-df joe': ['b', 'c', 'd'],
        'q B-3-df joe': ['b', 'c'],
        'd': ['a', 'q'],
        'h': ['c', 'd']
    }

    assert a3_functions.make_recommendations('a B-3-df joe', d_pp,d_pn) == [('q B-3-df joe',5),('h',4)], \
           'multiple mutual networks and multiple friends and last names'
コード例 #12
0
def test_make_recommendations_empty_string():
    d_pp = {
        's m': [],
        'A g': ['F p', 'A d', 'T-32'],
        'F p': ['A g', 'A d'],
        'Z b': ['T=32', 'A D']
    }
    d_pn = {
        's m': [],
        'A g':
        ['milliways restaurant', 'planet freepress', 'hitchhikers guild'],
        'A D': ['planet freepress', 'hitchhikers guild']
    }

    assert a3_functions.make_recommendations('', d_pp,d_pn) == [], \
           'Empty String '
コード例 #13
0
def test_make_recommendations_one_mutual_friend_one_mutual_networks():
    d_pp = {
        's m': ['F p'],
        'A g': ['F p', 'A d', 'T-32'],
        'F p': ['A g', 'A d'],
        'Z b': ['T=32', 'A D']
    }
    d_pn = {
        's m': ['milliways restaurant'],
        'A g':
        ['milliways restaurant', 'planet freepress', 'hitchhikers guild'],
        'A D': ['planet freepress', 'hitchhikers guild']
    }

    assert a3_functions.make_recommendations('s m', d_pp,d_pn) == [('A g',2)], \
           'one mutual friend and one mutual network'
コード例 #14
0
def test_make_recommendations_empty_string_and_dict():
    d_pp = {}
    d_pn = {}

    assert a3_functions.make_recommendations("", d_pp, d_pn) == [], "Empty String and both empty dictionaries"
コード例 #15
0
def test_make_recommendations_one_mutual_friend_same_last_name():
    d_pp = {"Arthur Dent": ["Ford Prefect"], "Trillian Dent": ["Ford Prefect"]}
    d_pn = {}
    assert a3_functions.make_recommendations("Arthur Dent", d_pp, d_pn) == [
        ("Trillian Dent", 2)
    ], "one mutual friend and same last name and empty networks dictionary"
コード例 #16
0
def test_make_recommendations_one_empty_dictionary():
    d_pp = {}
    d_pn = {"a": ["fefd"]}

    assert a3_functions.make_recommendations("Marvin So-Sad", d_pp, d_pn) == [], "one empty dictionary"
コード例 #17
0
def test_make_recommendations_one_mutual_friend_same_last_name():
    d_pp = {'Arthur Dent': ['Ford Prefect'], 'Trillian Dent': ['Ford Prefect']}
    d_pn = {}
    assert a3_functions.make_recommendations('Arthur Dent', d_pp,d_pn) == [('Trillian Dent',2)], \
           'one mutual friend and same last name and empty networks dictionary'
コード例 #18
0
def test_make_recommendations_one_mutual_network_same_last_name():
    d_pp = {'Arthur Dent': ['Ford Prefect'], 'Trillian Dent': ['Ford']}
    d_pn = {'Arthur Dent': ['milliways'], 'Trillian Dent': ['milliways']}
    assert a3_functions.make_recommendations('Arthur Dent', d_pp,d_pn) == [('Trillian Dent',2)], \
           'one mutual network and same last name, no mutual friends'
コード例 #19
0
def test_make_recommendations_empty_dictionaries():
    d_pp = {}
    d_pn = {}

    assert a3_functions.make_recommendations("Marvin So-Sad", d_pp, d_pn) == [], "Empty dictionaries"
コード例 #20
0
def test_make_recommendations_empty_dictionaries():
    d_pp = {}
    d_pn = {}

    assert a3_functions.make_recommendations('Marvin So-Sad', d_pp,d_pn) == [], \
           'Empty dictionaries'
コード例 #21
0
def test_make_recommendations_one_empty_dictionary():
    d_pp = {}
    d_pn = {'a': ['fefd']}

    assert a3_functions.make_recommendations('Marvin So-Sad', d_pp,d_pn) == [], \
           'one empty dictionary'
コード例 #22
0
def test_make_recommendations_empty_string_and_dict():
    d_pp = {}
    d_pn = {}

    assert a3_functions.make_recommendations('', d_pp,d_pn) == [], \
           'Empty String and both empty dictionaries'
コード例 #23
0
def test_make_recommendations_one_mutual_network_same_last_name():
    d_pp = {"Arthur Dent": ["Ford Prefect"], "Trillian Dent": ["Ford"]}
    d_pn = {"Arthur Dent": ["milliways"], "Trillian Dent": ["milliways"]}
    assert a3_functions.make_recommendations("Arthur Dent", d_pp, d_pn) == [
        ("Trillian Dent", 2)
    ], "one mutual network and same last name, no mutual friends"
コード例 #24
0
ファイル: a3_type_checks.py プロジェクト: Zhaeong/School
	'Haley Gwendolyn Dunphy': ['Dylan D-Money'], 
	'Phil Dunphy': ['Claire Dunphy', 'Luke Dunphy'], 
	'Dylan D-Money': ['Haley Gwendolyn Dunphy'], 
	'Gloria Pritchett': ['Jay Pritchett', 'Cameron Tucker', 'Manny Delgado'], 
	'Luke Dunphy': ['Manny Delgado', 'Alex Dunphy', 
	'Phil Dunphy', 'Mitchell Pritchett']}
	person_to_networks = \
	{'Phil Dunphy': ['Real Estate Association'], 
	'Claire Dunphy': ['Parent Teacher Association'], 
	'Manny Delgado': ['Chess Club'], 
	'Mitchell Pritchett': ['Law Association'], 
	'Alex Dunphy': ['Orchestra', 'Chess Club'], 
	'Cameron Tucker': ['Clown School', 'Wizard of Oz Fan Club'], 
	'Gloria Pritchett': ['Parent Teacher Association']}
	
	result = a3_functions.make_recommendations(\
	person, person_to_friends, person_to_networks)
	assert isinstance(result, list),\
	'''a3_functions.make_recommendations should return 
	a list of (str, int) tuples, but returned %s.''' % (type(result))

	for (name, score) in result:	
		assert isinstance(name, str),\
		'''a3_functions.make_recommendations should return a 
		list of (str, int) tuples, but the first element of a
		list tuple has %s.''' % (type(name))
		assert isinstance(score, int),\
		'''a3_functions.make_recommendations should return a 
		list of (str, int) tuples, but the second element of a 
		list tuple has %s.''' % (type(score))
		
		
コード例 #25
0
ファイル: a3_main.py プロジェクト: Zhaeong/School
import a3_functions

if __name__ == '__main__':

    # During testing, we may change the values of these variables.
    friendships = {}
    networks = {}
    profiles_file = open('profiles.txt')

    # Add your code here.
    person = 0
    while person != '':
        a3_functions.load_profiles(profiles_file, friendships, networks)
        person = raw_input("Please enter a person(or press return to exit):")
        recommendations = a3_functions.make_recommendations(
            person, friendships, networks)
        if recommendations == [] and person != '':
            print "There are no recommendations for this person."

        else:
            recomlist = a3_functions.sort_recommendations(recommendations)
            for names in recomlist:
                print names

    print "Thank you for using the recommendation system!"
コード例 #26
0
ファイル: a3_main.py プロジェクト: Zhaeong/School
import a3_functions
       
if __name__ == '__main__':
    
    # During testing, we may change the values of these variables.
    friendships = {}
    networks = {}
    profiles_file = open('profiles.txt')

    # Add your code here.  
    person = 0
    while person != '':
        a3_functions.load_profiles(profiles_file, friendships, networks)
        person = raw_input("Please enter a person(or press return to exit):")
        recommendations = a3_functions.make_recommendations(person, friendships,networks)
        if recommendations == [] and person != '':
            print "There are no recommendations for this person."
            
        else:
            recomlist = a3_functions.sort_recommendations(recommendations)
            for names in recomlist:
                print names
            
            
 
        
    print "Thank you for using the recommendation system!"