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"
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"
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"
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"
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"
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"
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 "
Exemple #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'
Exemple #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'
Exemple #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'
Exemple #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'
Exemple #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 '
Exemple #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'
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"
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"
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"
Exemple #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'
Exemple #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'
def test_make_recommendations_empty_dictionaries():
    d_pp = {}
    d_pn = {}

    assert a3_functions.make_recommendations("Marvin So-Sad", d_pp, d_pn) == [], "Empty dictionaries"
Exemple #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'
Exemple #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'
Exemple #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'
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"
Exemple #24
0
	'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))
		
		
Exemple #25
0
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!"
Exemple #26
0
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!"