Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

dist.csv New York Alaska Georgia Maryland Louisiana Montana North Dakota Idaho New York 4596.65 1498.22 346.17 2017.01 2201.13 1789.15 2908.73 Alaska 4706.62 4546.65 4608 4863.3

dist.csv

New York Alaska Georgia Maryland Louisiana Montana North Dakota Idaho
New York 4596.65 1498.22 346.17 2017.01 2201.13 1789.15 2908.73
Alaska 4706.62 4546.65 4608 4863.3 2791.38 3205.71 2781.08
Georgia 1453.81 5363.31 775.28 552.38 2408.26 1827.08 2715.37
Maryland 344.92 4542.12 750.95 1585.65 2146.6 1734.62 2854.2
Louisiana 1979.42 5025.53 555.13 1629.74 2070.48 2473.25 2377.59
Montana 2311.07 2639.06 2151.11 2212.45 2075.32 417.73 708.18
North Dakota 1897.01 3054.05 1737.05 1798.39 2476.66 415.57 1123.17
Idaho 3017.83 2779.8 2731.7 2919.21 2381.9 710.15 1124.49
Massachusetts 168.06 4854.02 1201.9 448 2274.38 2458.5 2046.52 3166.1
Nevada 3647.57 3174.69 2700.25 3297.89 2350.45 1069.56 1483.9 449.85

using python. Tour recommender Suppose, a friend of yours comes to the US for the first time and he/she wants to visit several places in the US. Now, you know the interesting things and places about the 50 states of the country. You ask you friend about his/her interests and then you suggest him/her to visit some of the states based on the interests. In this project, you have to act as a tour guide (in fact just a recommender). You are provided with a file states.csv containing the interesting things about each states in the US. You are also provided with a chart file dist.csv which contains state to state distance in a tabular format. You are given with the main function: def main(): stateInfo = read_state_file( 'states.csv' ) itemDict = build_itemDict( stateInfo ) personDatabase = read_person_file( 'person.csv' ) suggestion = make_suggestion( personDatabase, itemDict ) distanceMap = build_dist_map( 'dist.csv' ) (route, driveDist ) = calculate_min_route( distanceMap, suggestion['Someone'] ) print( route, driveDist ) As you can see, you have to use several functions in the main function, they will have to be defined by you. All the functions are described below: read_state_file o parameter: filename - string o returns: dictionary containing the interesting things about the states o description: reads file and stores the interesting things as values against each state as key in a dictionary o example: ? {'Alaska': ['wildlife', 'fishing', 'mountains', 'wilderness', 'glaciers', 'water sports', 'mountain sports'], ? 'Georgia': ['wilderness'], ? 'Louisiana': ['food', 'casinos'], ? 'Maryland': ['food', 'sports'], ? 'New York': ['business & industry', 'history', 'cityscape', 'food']} build_itemDict o parameter: stateInfo dictionary o returns: dictionary containing interesting things as keys and states as values o description: takes in the stateInfo dictionary and builds an itemDict dictionary which gathers all the states that include specific interesting thing as common o example: ? {'wildlife': ['Alaska'], ? 'fishing': ['Alaska'], ? 'mountains': ['Alaska'], ? 'wilderness': ['Alaska', 'Georgia'], ? 'glaciers': ['Alaska'], ? 'water sports': ['Alaska'], ? 'mountain sports': ['Alaska'], ? 'food': ['Louisiana', 'Maryland', 'New York'], ? 'casinos': ['Louisiana'], ? 'sports': ['Maryland'], ? 'business & industry': ['New York'], ? 'history': ['New York'], ? 'cityscape': ['New York']} read_person_file o parameter: filename - string o returns: dictionary containing the interesting things of persons o description: reads file and stores the interesting things as values against each person as key in a dictionary o example: ? {'Someone': ['beaches', 'mountains', 'mountain sports', 'fishing', 'sports'], ? 'Anyone': ['mines', 'glaciers', 'wildlife', 'wilderness'], ? 'None': ['food', 'cityscape'], ? 'Somebody': ['casinos', 'beaches', 'water sports', 'springs'], ? 'Nobody': ['history', 'cityscape', 'parks', 'lakes'], ? 'Everybody': ['food', 'waterfalls', 'farms', 'wilderness', 'wildlife', 'desert']} make_suggestion o parameter: personDatabase dictionary, itemDict - dictionary o returns: dictionary containing the suggested states for each person in the personDatabase o description: looks for persons interest and searches for the item in the itemDict, several interest generates several sets of collection of states, then performs a union operation and sets the sorted list of state as the value for the person as key in the returned dictionary o example: ? {'Someone': ['Alabama', 'Alaska', 'Arizona', 'California', 'Colorado', 'Delaware', 'Florida', 'Hawaii', 'Maryland', 'Massachusetts', 'Minnesota', 'Nebraska', 'New Hampshire', 'North Carolina', 'Ohio', 'South Carolina', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Washington'], ? 'Anyone': ['Alaska', 'Arizona', 'California', 'Colorado', 'Connecticut', 'Florida', 'Georgia', 'Idaho', 'Maine', 'Montana', 'North Dakota', 'Pennsylvania', 'South Dakota', 'Texas', 'Vermont', 'Washington', 'West Virginia', 'Wyoming'], ? 'None': ['Illinois', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Michigan', 'New Mexico', 'New York', 'North Carolina', 'Pennsylvania', 'Rhode Island', 'Tennessee', 'Texas', 'Vermont', 'Virginia', 'Washington DC', 'Wisconsin'], ? 'Somebody': ['Alaska', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Hawaii', 'Idaho', 'Louisiana', 'Maine', 'Minnesota', 'Mississippi', 'Missouri', 'Nevada', 'New Jersey', 'North Carolina', 'Ohio', 'Oregon', 'Rhode Island', 'South Carolina', 'Texas', 'Washington', 'West Virginia', 'Wyoming'], ? 'Nobody': ['Alabama', 'Arkansas', 'Florida', 'Hawaii', 'Illinois', 'Massachusetts', 'Michigan', 'Minnesota', 'Missouri', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'Utah', 'Vermont', 'Virginia', 'Washington DC', 'Wisconsin'], ? 'Everybody': ['Alaska', 'Arizona', 'California', 'Connecticut', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Michigan', 'Mississippi', 'Montana', 'Nebraska', 'Nevada', 'New Mexico', 'New York', 'North Carolina', 'Oregon', 'Pennsylvania', 'Rhode Island', 'Tennessee', 'Texas', 'Vermont', 'Virginia', 'Washington', 'Wisconsin', 'Wyoming']} build_dist_map o parameter: filename - string o returns: dictionary containing distance from each state to another o description: reads the file and stores the distance of a state from all other states in a dictionary, this dictionary is set as the value for the state for which the distance is measured as key for the returned dictionary o example: ? {'New York': {'New York': '', 'Alaska': '4596.65', 'Georgia': '1498.22', 'Maryland': '346.17', 'Louisiana': '2017.01'}, ? 'Alaska': {'New York': '4706.62', 'Alaska': '', 'Georgia': '4546.65', 'Maryland': '4608', 'Louisiana': '4863.3'}, ? 'Georgia': {'New York': '1453.81', 'Alaska': '5363.31', 'Georgia': '', 'Maryland': '775.28', 'Louisiana': '552.38'}, ? 'Maryland': {'New York': '344.92', 'Alaska': '4542.12', 'Georgia': '750.95', 'Maryland': '', 'Louisiana': '1585.65'}, ? 'Louisiana': {'New York': '1979.42', 'Alaska': '5025.53', 'Georgia': '555.13', 'Maryland': '1629.74'}} calculate_min_route o parameter: distanceMap dictionary, suggestion - list o returns: tuple containing a string route and a number driveDist o description: starting from the first state in the list, calculates and selects the closest state and then from that state again the next closest state and so on, builds a string comprising all the states selected sequentially and returns the total driving distance calculated o example: ? for a person having interest in food, he/she should visit Louisiana > Maryland > New York ? the driving distance he/she has to cover is 1974.66 states.csv; Alabama history sports Alaska wildlife fishing mountains wilderness glaciers water sports Arizona desert mountains mines Arkansas history springs water sports California beaches mountains wilderness business & industry water sports Colorado mountains springs mines water sports mountain sports

person.csv

Someone

beaches mountains mountain sports fishing
Anyone mines glaciers wildlife wilderness
None food cityscape
Somebody casinos beaches water sports springs
Nobody history cityscape parks lakes
Everybody food

waterfalls states.csv

farms

Alabama history sports
Alaska wildlife fishing
Arizona desert mountains
Arkansas history springs
California beaches mountains

wilderness

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

3642412203, 978-3642412202

More Books

Students also viewed these Databases questions

Question

7. What can we learn about a culture through its texts?

Answered: 1 week ago