update,
This commit is contained in:
439
tunmnlu/task_1/Q1/Q1.py
Normal file
439
tunmnlu/task_1/Q1/Q1.py
Normal file
@@ -0,0 +1,439 @@
|
||||
import http.client
|
||||
import json
|
||||
import csv
|
||||
import urllib.request
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
# cse6242
|
||||
# All instructions, code comments, etc. contained within this notebook are part of the assignment instructions.
|
||||
# Portions of this file will auto-graded in Gradescope using different sets of parameters / data to ensure that values are not
|
||||
# hard-coded.
|
||||
#
|
||||
# Instructions: Implement all methods in this file that have a return
|
||||
# value of 'NotImplemented'. See the documentation within each method for specific details, including
|
||||
# the expected return value
|
||||
#
|
||||
# Helper Functions:
|
||||
# You are permitted to write additional helper functions/methods or use additional instance variables within
|
||||
# the `Graph` class or `TMDbAPIUtils` class so long as the originally included methods work as required.
|
||||
#
|
||||
# Use:
|
||||
# The `Graph` class is used to represent and store the data for the TMDb co-actor network graph. This class must
|
||||
# also provide some basic analytics, i.e., number of nodes, edges, and nodes with the highest degree.
|
||||
#
|
||||
# The `TMDbAPIUtils` class is used to retrieve Actor/Movie data using themoviedb.org API. We have provided a few necessary methods
|
||||
# to test your code w/ the API, e.g.: get_movie_cast(), get_movie_credits_for_person(). You may add additional
|
||||
# methods and instance variables as desired (see Helper Functions).
|
||||
#
|
||||
# The data that you retrieve from the TMDb API is used to build your graph using the Graph class. After you build your graph using the
|
||||
# TMDb API data, use the Graph class write_edges_file & write_nodes_file methods to produce the separate nodes and edges
|
||||
# .csv files for submission to Gradescope.
|
||||
#
|
||||
# While building the co-actor graph, you will be required to write code to expand the graph by iterating
|
||||
# through a portion of the graph nodes and finding similar artists using the TMDb API. We will not grade this code directly
|
||||
# but will grade the resulting graph data in your nodes and edges .csv files.
|
||||
#
|
||||
#############################################################################################################################
|
||||
|
||||
|
||||
class Graph:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, with_nodes_file=None, with_edges_file=None):
|
||||
"""
|
||||
option 1: init as an empty graph and add nodes
|
||||
option 2: init by specifying a path to nodes & edges files
|
||||
"""
|
||||
self.nodes = []
|
||||
self.edges = []
|
||||
if with_nodes_file and with_edges_file:
|
||||
nodes_CSV = csv.reader(open(with_nodes_file))
|
||||
nodes_CSV = list(nodes_CSV)[1:]
|
||||
self.nodes = [(n[0], n[1]) for n in nodes_CSV]
|
||||
|
||||
edges_CSV = csv.reader(open(with_edges_file))
|
||||
edges_CSV = list(edges_CSV)[1:]
|
||||
self.edges = [(e[0], e[1]) for e in edges_CSV]
|
||||
|
||||
|
||||
def add_node(self, id: str, name: str) -> None:
|
||||
"""
|
||||
add a tuple (id, name) representing a node to self.nodes if it does not already exist
|
||||
The graph should not contain any duplicate nodes
|
||||
"""
|
||||
self.nodes.append((id, name))
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def add_edge(self, source: str, target: str) -> None:
|
||||
"""
|
||||
Add an edge between two nodes if it does not already exist.
|
||||
An edge is represented by a tuple containing two strings: e.g.: ('source', 'target').
|
||||
Where 'source' is the id of the source node and 'target' is the id of the target node
|
||||
e.g., for two nodes with ids 'a' and 'b' respectively, add the tuple ('a', 'b') to self.edges
|
||||
"""
|
||||
self.edges.append((source, target))
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def total_nodes(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of nodes in the graph
|
||||
"""
|
||||
output = len(self.nodes)
|
||||
return output
|
||||
|
||||
def total_edges(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of edges in the graph
|
||||
"""
|
||||
output = len(self.edges)
|
||||
return output
|
||||
|
||||
def max_degree_nodes(self) -> dict:
|
||||
"""
|
||||
Return the node(s) with the highest degree
|
||||
Return multiple nodes in the event of a tie
|
||||
Format is a dict where the key is the node_id and the value is an integer for the node degree
|
||||
e.g. {'a': 8}
|
||||
or {'a': 22, 'b': 22}
|
||||
"""
|
||||
|
||||
max_degree_nodes = {}
|
||||
|
||||
for edge in self.edges:
|
||||
for idx in edge:
|
||||
if idx in max_degree_nodes:
|
||||
max_degree_nodes[idx] += 1
|
||||
else:
|
||||
max_degree_nodes[idx] = 1
|
||||
|
||||
v = list(max_degree_nodes.values())
|
||||
k = list(max_degree_nodes.keys())
|
||||
max_nodes = {k[v.index(max(v))]: max(v)}
|
||||
return max_nodes
|
||||
|
||||
def print_nodes(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.nodes)
|
||||
|
||||
|
||||
def print_edges(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.edges)
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_edges_file(self, path="edges.csv")->None:
|
||||
"""
|
||||
write all edges out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
edges_path = path
|
||||
edges_file = open(edges_path, 'w', encoding='utf-8')
|
||||
|
||||
edges_file.write("source" + "," + "target" + "\n")
|
||||
|
||||
for e in self.edges:
|
||||
edges_file.write(e[0] + "," + e[1] + "\n")
|
||||
|
||||
edges_file.close()
|
||||
print("finished writing edges to csv")
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_nodes_file(self, path="nodes.csv")->None:
|
||||
"""
|
||||
write all nodes out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
nodes_path = path
|
||||
nodes_file = open(nodes_path, 'w', encoding='utf-8')
|
||||
|
||||
nodes_file.write("id,name" + "\n")
|
||||
for n in self.nodes:
|
||||
nodes_file.write(n[0] + "," + n[1] + "\n")
|
||||
nodes_file.close()
|
||||
print("finished writing nodes to csv")
|
||||
|
||||
|
||||
|
||||
class TMDBAPIUtils:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, api_key:str):
|
||||
self.api_key=api_key
|
||||
|
||||
|
||||
def get_movie_cast(self, movie_id:str, limit:int=None, exclude_ids:list=None) -> list:
|
||||
"""
|
||||
Get the movie cast for a given movie id, with optional parameters to exclude an cast member
|
||||
from being returned and/or to limit the number of returned cast members
|
||||
documentation url: https://developers.themoviedb.org/3/movies/get-movie-credits
|
||||
|
||||
:param string movie_id: a movie_id
|
||||
:param list exclude_ids: a list of ints containing ids (not cast_ids) of cast members that should be excluded from the returned result
|
||||
e.g., if exclude_ids are [353, 455] then exclude these from any result.
|
||||
:param integer limit: maximum number of returned cast members by their 'order' attribute
|
||||
e.g., limit=5 will attempt to return the 5 cast members having 'order' attribute values between 0-4
|
||||
If after excluding, there are fewer cast members than the specified limit, then return the remaining members (excluding the ones whose order values are outside the limit range).
|
||||
If cast members with 'order' attribute in the specified limit range have been excluded, do not include more cast members to reach the limit.
|
||||
If after excluding, the limit is not specified, then return all remaining cast members."
|
||||
e.g., if limit=5 and the actor whose id corresponds to cast member with order=1 is to be excluded,
|
||||
return cast members with order values [0, 2, 3, 4], not [0, 2, 3, 4, 5]
|
||||
:rtype: list
|
||||
return a list of dicts, one dict per cast member with the following structure:
|
||||
[{'id': '97909' # the id of the cast member
|
||||
'character': 'John Doe' # the name of the character played
|
||||
'credit_id': '52fe4249c3a36847f8012927' # id of the credit, ...}, ... ]
|
||||
Note that this is an example of the structure of the list and some of the fields returned by the API.
|
||||
The result of the API call will include many more fields for each cast member.
|
||||
"""
|
||||
|
||||
url = 'https://api.themoviedb.org/3/movie/'+ str(movie_id) +'/credits?api_key='+self.api_key +"&language=en-US"
|
||||
req = urllib.request.Request(url, headers={
|
||||
'Accept': 'application/json',
|
||||
})
|
||||
response = urllib.request.urlopen(req)
|
||||
if response.status == 200:
|
||||
json_data = json.load(response)
|
||||
cast = json_data['cast']
|
||||
if exclude_ids is not None:
|
||||
cast = [i for i in cast if i['id'] not in exclude_ids]
|
||||
# print(cast)
|
||||
if limit is not None:
|
||||
cast = [i for i in cast if i['order'] < limit]
|
||||
# print(cast)
|
||||
for c in cast:
|
||||
c['name'] = c['name'].replace(',', '')
|
||||
return cast
|
||||
else:
|
||||
print(response.status.__str__())
|
||||
return None
|
||||
|
||||
def get_movie_credits_for_person(self, person_id:str, vote_avg_threshold:float=None)->list:
|
||||
"""
|
||||
Using the TMDb API, get the movie credits for a person serving in a cast role
|
||||
documentation url: https://developers.themoviedb.org/3/people/get-person-movie-credits
|
||||
|
||||
:param string person_id: the id of a person
|
||||
:param vote_avg_threshold: optional parameter to return the movie credit if it is >=
|
||||
the specified threshold.
|
||||
e.g., if the vote_avg_threshold is 5.0, then only return credits with a vote_avg >= 5.0
|
||||
:rtype: list
|
||||
return a list of dicts, with each dict having 'id', 'title', and 'vote_avg' keys,
|
||||
one dict per movie credit with the following structure:
|
||||
[{'id': '97909' # the id of the movie
|
||||
'title': 'Long, Stock and Two Smoking Barrels' # the title (not original title) of the credit
|
||||
'vote_avg': 5.0 # the float value of the vote average value for the credit}, ... ]
|
||||
"""
|
||||
url = 'https://api.themoviedb.org/3/person/'+ str(person_id) +'/movie_credits?api_key='+self.api_key+'&language=en-US'
|
||||
req = urllib.request.Request(url, headers={
|
||||
'Accept': 'application/json',
|
||||
})
|
||||
response = urllib.request.urlopen(req)
|
||||
|
||||
if response.status == 200:
|
||||
json_data = json.load(response)
|
||||
raw_credits = json_data['cast']
|
||||
if vote_avg_threshold is not None:
|
||||
filtered_credits = []
|
||||
for idx in raw_credits:
|
||||
if idx["vote_average"] >= vote_avg_threshold:
|
||||
filtered_credits.append({
|
||||
"id":idx["id"],
|
||||
"title":idx["title"],
|
||||
"vote_avg":idx["vote_average"]
|
||||
})
|
||||
return filtered_credits
|
||||
else:
|
||||
unfiltered_credits = []
|
||||
for idx in raw_credits:
|
||||
unfiltered_credits.append({
|
||||
"id":idx["id"],
|
||||
"title":idx["title"],
|
||||
"vote_avg":idx["vote_average"]
|
||||
})
|
||||
return unfiltered_credits
|
||||
else:
|
||||
print("ERROR: " + response.status.__str__())
|
||||
return None
|
||||
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
#
|
||||
# BUILDING YOUR GRAPH
|
||||
#
|
||||
# Working with the API: See use of http.request: https://docs.python.org/3/library/http.client.html#examples
|
||||
#
|
||||
# Using TMDb's API, build a co-actor network for the actor's/actress' highest rated movies
|
||||
# In this graph, each node represents an actor
|
||||
# An edge between any two nodes indicates that the two actors/actresses acted in a movie together
|
||||
# i.e., they share a movie credit.
|
||||
# e.g., An edge between Samuel L. Jackson and Robert Downey Jr. indicates that they have acted in one
|
||||
# or more movies together.
|
||||
#
|
||||
# For this assignment, we are interested in a co-actor network of highly rated movies; specifically,
|
||||
# we only want the top 3 co-actors in each movie credit of an actor having a vote average >= 8.0.
|
||||
# Build your co-actor graph on the actor 'Laurence Fishburne' w/ person_id 2975.
|
||||
#
|
||||
# You will need to add extra functions or code to accomplish this. We will not directly call or explicitly grade your
|
||||
# algorithm. We will instead measure the correctness of your output by evaluating the data in your nodes.csv and edges.csv files.
|
||||
#
|
||||
# GRAPH SIZE
|
||||
# With each iteration of your graph build, the number of nodes and edges grows approximately at an exponential rate.
|
||||
# Our testing indicates growth approximately equal to e^2x.
|
||||
# Since the TMDB API is a live database, the number of nodes / edges in the final graph will vary slightly depending on when
|
||||
# you execute your graph building code. We take this into account by rebuilding the solution graph every few days and
|
||||
# updating the auto-grader. We establish a bound for lowest & highest encountered numbers of nodes and edges with a
|
||||
# margin of +/- 100 for nodes and +/- 150 for edges. e.g., The allowable range of nodes is set to:
|
||||
#
|
||||
# Min allowable nodes = min encountered nodes - 100
|
||||
# Max allowable nodes = max allowable nodes + 100
|
||||
#
|
||||
# e.g., if the minimum encountered nodes = 507 and the max encountered nodes = 526, then the min/max range is 407-626
|
||||
# The same method is used to calculate the edges with the exception of using the aforementioned edge margin.
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
# BEGIN BUILD CO-ACTOR NETWORK
|
||||
#
|
||||
# INITIALIZE GRAPH
|
||||
# Initialize a Graph object with a single node representing Laurence Fishburne
|
||||
#
|
||||
# BEGIN BUILD BASE GRAPH:
|
||||
# Find all of Laurence Fishburne's movie credits that have a vote average >= 8.0
|
||||
# FOR each movie credit:
|
||||
# | get the movie cast members having an 'order' value between 0-2 (these are the co-actors)
|
||||
# |
|
||||
# | FOR each movie cast member:
|
||||
# | | using graph.add_node(), add the movie cast member as a node (keep track of all new nodes added to the graph)
|
||||
# | | using graph.add_edge(), add an edge between the Laurence Fishburne (actor) node
|
||||
# | | and each new node (co-actor/co-actress)
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END BUILD BASE GRAPH
|
||||
#
|
||||
#
|
||||
# BEGIN LOOP - DO 2 TIMES:
|
||||
# IF first iteration of loop:
|
||||
# | nodes = The nodes added in the BUILD BASE GRAPH (this excludes the original node of Laurence Fishburne!)
|
||||
# ELSE
|
||||
# | nodes = The nodes added in the previous iteration:
|
||||
# ENDIF
|
||||
#
|
||||
# FOR each node in nodes:
|
||||
# | get the movie credits for the actor that have a vote average >= 8.0
|
||||
# |
|
||||
# | FOR each movie credit:
|
||||
# | | try to get the 3 movie cast members having an 'order' value between 0-2
|
||||
# | |
|
||||
# | | FOR each movie cast member:
|
||||
# | | | IF the node doesn't already exist:
|
||||
# | | | | add the node to the graph (track all new nodes added to the graph)
|
||||
# | | | ENDIF
|
||||
# | | |
|
||||
# | | | IF the edge does not exist:
|
||||
# | | | | add an edge between the node (actor) and the new node (co-actor/co-actress)
|
||||
# | | | ENDIF
|
||||
# | | END FOR
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END LOOP
|
||||
#
|
||||
# Your graph should not have any duplicate edges or nodes
|
||||
# Write out your finished graph as a nodes file and an edges file using:
|
||||
# graph.write_edges_file()
|
||||
# graph.write_nodes_file()
|
||||
#
|
||||
# END BUILD CO-ACTOR NETWORK
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Exception handling and best practices
|
||||
# - You should use the param 'language=en-US' in all API calls to avoid encoding issues when writing data to file.
|
||||
# - If the actor name has a comma char ',' it should be removed to prevent extra columns from being inserted into the .csv file
|
||||
# - Some movie_credits do not return cast data. Handle this situation by skipping these instances.
|
||||
# - While The TMDb API does not have a rate-limiting scheme in place, consider that making hundreds / thousands of calls
|
||||
# can occasionally result in timeout errors. If you continue to experience 'ConnectionRefusedError : [Errno 61] Connection refused',
|
||||
# - wait a while and then try again. It may be necessary to insert periodic sleeps when you are building your graph.
|
||||
|
||||
|
||||
def return_name()->str:
|
||||
"""
|
||||
Return a string containing your GT Username
|
||||
e.g., tlou31
|
||||
Do not return your 9 digit GTId
|
||||
"""
|
||||
return "tlou31"
|
||||
|
||||
# You should modify __main__ as you see fit to build/test your graph using the TMDBAPIUtils & Graph classes.
|
||||
# Some boilerplate/sample code is provided for demonstration. We will not call __main__ during grading.
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
graph = Graph()
|
||||
graph.add_node(id='2975', name='Laurence Fishburne')
|
||||
|
||||
# build base graph
|
||||
# find all laurence fishburne's movie credits with a vote average >= 8.0
|
||||
tmdb_api_utils = TMDBAPIUtils(api_key='1eed362096d67d9f077084d5abb30a35')
|
||||
movie_credits = tmdb_api_utils.get_movie_credits_for_person(person_id='2975', vote_avg_threshold=8.0)
|
||||
|
||||
# for each movie credit get movie cast members having and order value between 0-2 (3 0-base)
|
||||
for movie in movie_credits:
|
||||
movie_cast = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for cast_member in movie_cast:
|
||||
graph.add_node(str(cast_member['id']), cast_member['name'])
|
||||
graph.add_edge(source='2975', target=str(cast_member['id']))
|
||||
break
|
||||
break
|
||||
|
||||
for i in range(2+1):
|
||||
print('running loop ' + str(i))
|
||||
if i == 0:
|
||||
current_nodes = graph.nodes[1:]
|
||||
else:
|
||||
current_nodes = [i for i in graph.nodes if i not in current_nodes]
|
||||
|
||||
for node in current_nodes:
|
||||
cast = tmdb_api_utils.get_movie_credits_for_person(person_id=node[0], vote_avg_threshold=8.0)
|
||||
for movie in cast:
|
||||
actors = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for actor in actors:
|
||||
if((str(actor['id']), actor['name']) not in graph.nodes):
|
||||
graph.add_node(str(actor['id']), actor['name'])
|
||||
|
||||
source = str(node[0])
|
||||
target = str(actor['id'])
|
||||
current_edge = (source, target)
|
||||
current_edge_inverted = (target, source)
|
||||
edges = graph.edges
|
||||
if (source != target) and (current_edge not in edges) and (current_edge_inverted not in edges):
|
||||
graph.add_edge(source , target )
|
||||
|
||||
# tmdb_api_utils.get_movie_cast(movie_id='100', limit=3, exclude_ids=[973, 974])
|
||||
# tmdb_api_utils.get_movie_credits_for_person(person_id="9709", vote_avg_threshold=5.0)
|
||||
|
||||
# call functions or place code here to build graph (graph building code not graded)
|
||||
# Suggestion: code should contain steps outlined above in BUILD CO-ACTOR NETWORK
|
||||
|
||||
print(f"Edges: {graph.total_edges()}")
|
||||
print(f"Nodes: {graph.total_nodes()}")
|
||||
|
||||
graph.write_edges_file()
|
||||
graph.write_nodes_file()
|
||||
|
||||
# If you have already built & written out your graph, you could read in your nodes & edges files
|
||||
# to perform testing on your graph.
|
||||
graph = Graph(with_edges_file="edges.csv", with_nodes_file="nodes.csv")
|
||||
print(graph.max_degree_nodes())
|
330
tunmnlu/task_1/Q1/Q1_question.py
Normal file
330
tunmnlu/task_1/Q1/Q1_question.py
Normal file
@@ -0,0 +1,330 @@
|
||||
import http.client
|
||||
import json
|
||||
import csv
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
# cse6242
|
||||
# All instructions, code comments, etc. contained within this notebook are part of the assignment instructions.
|
||||
# Portions of this file will auto-graded in Gradescope using different sets of parameters / data to ensure that values are not
|
||||
# hard-coded.
|
||||
#
|
||||
# Instructions: Implement all methods in this file that have a return
|
||||
# value of 'NotImplemented'. See the documentation within each method for specific details, including
|
||||
# the expected return value
|
||||
#
|
||||
# Helper Functions:
|
||||
# You are permitted to write additional helper functions/methods or use additional instance variables within
|
||||
# the `Graph` class or `TMDbAPIUtils` class so long as the originally included methods work as required.
|
||||
#
|
||||
# Use:
|
||||
# The `Graph` class is used to represent and store the data for the TMDb co-actor network graph. This class must
|
||||
# also provide some basic analytics, i.e., number of nodes, edges, and nodes with the highest degree.
|
||||
#
|
||||
# The `TMDbAPIUtils` class is used to retrieve Actor/Movie data using themoviedb.org API. We have provided a few necessary methods
|
||||
# to test your code w/ the API, e.g.: get_movie_cast(), get_movie_credits_for_person(). You may add additional
|
||||
# methods and instance variables as desired (see Helper Functions).
|
||||
#
|
||||
# The data that you retrieve from the TMDb API is used to build your graph using the Graph class. After you build your graph using the
|
||||
# TMDb API data, use the Graph class write_edges_file & write_nodes_file methods to produce the separate nodes and edges
|
||||
# .csv files for submission to Gradescope.
|
||||
#
|
||||
# While building the co-actor graph, you will be required to write code to expand the graph by iterating
|
||||
# through a portion of the graph nodes and finding similar artists using the TMDb API. We will not grade this code directly
|
||||
# but will grade the resulting graph data in your nodes and edges .csv files.
|
||||
#
|
||||
#############################################################################################################################
|
||||
|
||||
|
||||
class Graph:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, with_nodes_file=None, with_edges_file=None):
|
||||
"""
|
||||
option 1: init as an empty graph and add nodes
|
||||
option 2: init by specifying a path to nodes & edges files
|
||||
"""
|
||||
self.nodes = []
|
||||
self.edges = []
|
||||
if with_nodes_file and with_edges_file:
|
||||
nodes_CSV = csv.reader(open(with_nodes_file))
|
||||
nodes_CSV = list(nodes_CSV)[1:]
|
||||
self.nodes = [(n[0], n[1]) for n in nodes_CSV]
|
||||
|
||||
edges_CSV = csv.reader(open(with_edges_file))
|
||||
edges_CSV = list(edges_CSV)[1:]
|
||||
self.edges = [(e[0], e[1]) for e in edges_CSV]
|
||||
|
||||
|
||||
def add_node(self, id: str, name: str) -> None:
|
||||
"""
|
||||
add a tuple (id, name) representing a node to self.nodes if it does not already exist
|
||||
The graph should not contain any duplicate nodes
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def add_edge(self, source: str, target: str) -> None:
|
||||
"""
|
||||
Add an edge between two nodes if it does not already exist.
|
||||
An edge is represented by a tuple containing two strings: e.g.: ('source', 'target').
|
||||
Where 'source' is the id of the source node and 'target' is the id of the target node
|
||||
e.g., for two nodes with ids 'a' and 'b' respectively, add the tuple ('a', 'b') to self.edges
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def total_nodes(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of nodes in the graph
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def total_edges(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of edges in the graph
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def max_degree_nodes(self) -> dict:
|
||||
"""
|
||||
Return the node(s) with the highest degree
|
||||
Return multiple nodes in the event of a tie
|
||||
Format is a dict where the key is the node_id and the value is an integer for the node degree
|
||||
e.g. {'a': 8}
|
||||
or {'a': 22, 'b': 22}
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def print_nodes(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.nodes)
|
||||
|
||||
|
||||
def print_edges(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.edges)
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_edges_file(self, path="edges.csv")->None:
|
||||
"""
|
||||
write all edges out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
edges_path = path
|
||||
edges_file = open(edges_path, 'w', encoding='utf-8')
|
||||
|
||||
edges_file.write("source" + "," + "target" + "\n")
|
||||
|
||||
for e in self.edges:
|
||||
edges_file.write(e[0] + "," + e[1] + "\n")
|
||||
|
||||
edges_file.close()
|
||||
print("finished writing edges to csv")
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_nodes_file(self, path="nodes.csv")->None:
|
||||
"""
|
||||
write all nodes out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
nodes_path = path
|
||||
nodes_file = open(nodes_path, 'w', encoding='utf-8')
|
||||
|
||||
nodes_file.write("id,name" + "\n")
|
||||
for n in self.nodes:
|
||||
nodes_file.write(n[0] + "," + n[1] + "\n")
|
||||
nodes_file.close()
|
||||
print("finished writing nodes to csv")
|
||||
|
||||
|
||||
|
||||
class TMDBAPIUtils:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, api_key:str):
|
||||
self.api_key=api_key
|
||||
|
||||
|
||||
def get_movie_cast(self, movie_id:str, limit:int=None, exclude_ids:list=None) -> list:
|
||||
"""
|
||||
Get the movie cast for a given movie id, with optional parameters to exclude an cast member
|
||||
from being returned and/or to limit the number of returned cast members
|
||||
documentation url: https://developers.themoviedb.org/3/movies/get-movie-credits
|
||||
|
||||
:param string movie_id: a movie_id
|
||||
:param list exclude_ids: a list of ints containing ids (not cast_ids) of cast members that should be excluded from the returned result
|
||||
e.g., if exclude_ids are [353, 455] then exclude these from any result.
|
||||
:param integer limit: maximum number of returned cast members by their 'order' attribute
|
||||
e.g., limit=5 will attempt to return the 5 cast members having 'order' attribute values between 0-4
|
||||
If after excluding, there are fewer cast members than the specified limit, then return the remaining members (excluding the ones whose order values are outside the limit range).
|
||||
If cast members with 'order' attribute in the specified limit range have been excluded, do not include more cast members to reach the limit.
|
||||
If after excluding, the limit is not specified, then return all remaining cast members."
|
||||
e.g., if limit=5 and the actor whose id corresponds to cast member with order=1 is to be excluded,
|
||||
return cast members with order values [0, 2, 3, 4], not [0, 2, 3, 4, 5]
|
||||
:rtype: list
|
||||
return a list of dicts, one dict per cast member with the following structure:
|
||||
[{'id': '97909' # the id of the cast member
|
||||
'character': 'John Doe' # the name of the character played
|
||||
'credit_id': '52fe4249c3a36847f8012927' # id of the credit, ...}, ... ]
|
||||
Note that this is an example of the structure of the list and some of the fields returned by the API.
|
||||
The result of the API call will include many more fields for each cast member.
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def get_movie_credits_for_person(self, person_id:str, vote_avg_threshold:float=None)->list:
|
||||
"""
|
||||
Using the TMDb API, get the movie credits for a person serving in a cast role
|
||||
documentation url: https://developers.themoviedb.org/3/people/get-person-movie-credits
|
||||
|
||||
:param string person_id: the id of a person
|
||||
:param vote_avg_threshold: optional parameter to return the movie credit if it is >=
|
||||
the specified threshold.
|
||||
e.g., if the vote_avg_threshold is 5.0, then only return credits with a vote_avg >= 5.0
|
||||
:rtype: list
|
||||
return a list of dicts, with each dict having 'id', 'title', and 'vote_avg' keys,
|
||||
one dict per movie credit with the following structure:
|
||||
[{'id': '97909' # the id of the movie
|
||||
'title': 'Long, Stock and Two Smoking Barrels' # the title (not original title) of the credit
|
||||
'vote_avg': 5.0 # the float value of the vote average value for the credit}, ... ]
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
#
|
||||
# BUILDING YOUR GRAPH
|
||||
#
|
||||
# Working with the API: See use of http.request: https://docs.python.org/3/library/http.client.html#examples
|
||||
#
|
||||
# Using TMDb's API, build a co-actor network for the actor's/actress' highest rated movies
|
||||
# In this graph, each node represents an actor
|
||||
# An edge between any two nodes indicates that the two actors/actresses acted in a movie together
|
||||
# i.e., they share a movie credit.
|
||||
# e.g., An edge between Samuel L. Jackson and Robert Downey Jr. indicates that they have acted in one
|
||||
# or more movies together.
|
||||
#
|
||||
# For this assignment, we are interested in a co-actor network of highly rated movies; specifically,
|
||||
# we only want the top 3 co-actors in each movie credit of an actor having a vote average >= 8.0.
|
||||
# Build your co-actor graph on the actor 'Laurence Fishburne' w/ person_id 2975.
|
||||
#
|
||||
# You will need to add extra functions or code to accomplish this. We will not directly call or explicitly grade your
|
||||
# algorithm. We will instead measure the correctness of your output by evaluating the data in your nodes.csv and edges.csv files.
|
||||
#
|
||||
# GRAPH SIZE
|
||||
# With each iteration of your graph build, the number of nodes and edges grows approximately at an exponential rate.
|
||||
# Our testing indicates growth approximately equal to e^2x.
|
||||
# Since the TMDB API is a live database, the number of nodes / edges in the final graph will vary slightly depending on when
|
||||
# you execute your graph building code. We take this into account by rebuilding the solution graph every few days and
|
||||
# updating the auto-grader. We establish a bound for lowest & highest encountered numbers of nodes and edges with a
|
||||
# margin of +/- 100 for nodes and +/- 150 for edges. e.g., The allowable range of nodes is set to:
|
||||
#
|
||||
# Min allowable nodes = min encountered nodes - 100
|
||||
# Max allowable nodes = max allowable nodes + 100
|
||||
#
|
||||
# e.g., if the minimum encountered nodes = 507 and the max encountered nodes = 526, then the min/max range is 407-626
|
||||
# The same method is used to calculate the edges with the exception of using the aforementioned edge margin.
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
# BEGIN BUILD CO-ACTOR NETWORK
|
||||
#
|
||||
# INITIALIZE GRAPH
|
||||
# Initialize a Graph object with a single node representing Laurence Fishburne
|
||||
#
|
||||
# BEGIN BUILD BASE GRAPH:
|
||||
# Find all of Laurence Fishburne's movie credits that have a vote average >= 8.0
|
||||
# FOR each movie credit:
|
||||
# | get the movie cast members having an 'order' value between 0-2 (these are the co-actors)
|
||||
# |
|
||||
# | FOR each movie cast member:
|
||||
# | | using graph.add_node(), add the movie cast member as a node (keep track of all new nodes added to the graph)
|
||||
# | | using graph.add_edge(), add an edge between the Laurence Fishburne (actor) node
|
||||
# | | and each new node (co-actor/co-actress)
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END BUILD BASE GRAPH
|
||||
#
|
||||
#
|
||||
# BEGIN LOOP - DO 2 TIMES:
|
||||
# IF first iteration of loop:
|
||||
# | nodes = The nodes added in the BUILD BASE GRAPH (this excludes the original node of Laurence Fishburne!)
|
||||
# ELSE
|
||||
# | nodes = The nodes added in the previous iteration:
|
||||
# ENDIF
|
||||
#
|
||||
# FOR each node in nodes:
|
||||
# | get the movie credits for the actor that have a vote average >= 8.0
|
||||
# |
|
||||
# | FOR each movie credit:
|
||||
# | | try to get the 3 movie cast members having an 'order' value between 0-2
|
||||
# | |
|
||||
# | | FOR each movie cast member:
|
||||
# | | | IF the node doesn't already exist:
|
||||
# | | | | add the node to the graph (track all new nodes added to the graph)
|
||||
# | | | ENDIF
|
||||
# | | |
|
||||
# | | | IF the edge does not exist:
|
||||
# | | | | add an edge between the node (actor) and the new node (co-actor/co-actress)
|
||||
# | | | ENDIF
|
||||
# | | END FOR
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END LOOP
|
||||
#
|
||||
# Your graph should not have any duplicate edges or nodes
|
||||
# Write out your finished graph as a nodes file and an edges file using:
|
||||
# graph.write_edges_file()
|
||||
# graph.write_nodes_file()
|
||||
#
|
||||
# END BUILD CO-ACTOR NETWORK
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Exception handling and best practices
|
||||
# - You should use the param 'language=en-US' in all API calls to avoid encoding issues when writing data to file.
|
||||
# - If the actor name has a comma char ',' it should be removed to prevent extra columns from being inserted into the .csv file
|
||||
# - Some movie_credits do not return cast data. Handle this situation by skipping these instances.
|
||||
# - While The TMDb API does not have a rate-limiting scheme in place, consider that making hundreds / thousands of calls
|
||||
# can occasionally result in timeout errors. If you continue to experience 'ConnectionRefusedError : [Errno 61] Connection refused',
|
||||
# - wait a while and then try again. It may be necessary to insert periodic sleeps when you are building your graph.
|
||||
|
||||
|
||||
def return_name()->str:
|
||||
"""
|
||||
Return a string containing your GT Username
|
||||
e.g., tlou31
|
||||
Do not return your 9 digit GTId
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
# You should modify __main__ as you see fit to build/test your graph using the TMDBAPIUtils & Graph classes.
|
||||
# Some boilerplate/sample code is provided for demonstration. We will not call __main__ during grading.
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
graph = Graph()
|
||||
graph.add_node(id='2975', name='Laurence Fishburne')
|
||||
tmdb_api_utils = TMDBAPIUtils(api_key='<your API key>')
|
||||
|
||||
# call functions or place code here to build graph (graph building code not graded)
|
||||
# Suggestion: code should contain steps outlined above in BUILD CO-ACTOR NETWORK
|
||||
|
||||
graph.write_edges_file()
|
||||
graph.write_nodes_file()
|
||||
|
||||
# If you have already built & written out your graph, you could read in your nodes & edges files
|
||||
# to perform testing on your graph.
|
||||
# graph = Graph(with_edges_file="edges.csv", with_nodes_file="nodes.csv")
|
446
tunmnlu/task_1/Q1/Q1_ref.py
Normal file
446
tunmnlu/task_1/Q1/Q1_ref.py
Normal file
@@ -0,0 +1,446 @@
|
||||
import http.client
|
||||
import json
|
||||
import csv
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
# cse6242
|
||||
# All instructions, code comments, etc. contained within this notebook are part of the assignment instructions.
|
||||
# Portions of this file will auto-graded in Gradescope using different sets of parameters / data to ensure that values are not
|
||||
# hard-coded.
|
||||
#
|
||||
# Instructions: Implement all methods in this file that have a return
|
||||
# value of 'NotImplemented'. See the documentation within each method for specific details, including
|
||||
# the expected return value
|
||||
#
|
||||
# Helper Functions:
|
||||
# You are permitted to write additional helper functions/methods or use additional instance variables within
|
||||
# the `Graph` class or `TMDbAPIUtils` class so long as the originally included methods work as required.
|
||||
#
|
||||
# Use:
|
||||
# The `Graph` class is used to represent and store the data for the TMDb co-actor network graph. This class must
|
||||
# also provide some basic analytics, i.e., number of nodes, edges, and nodes with the highest degree.
|
||||
#
|
||||
# The `TMDbAPIUtils` class is used to retrieve Actor/Movie data using themoviedb.org API. We have provided a few necessary methods
|
||||
# to test your code w/ the API, e.g.: get_movie_cast(), get_movie_credits_for_person(). You may add additional
|
||||
# methods and instance variables as desired (see Helper Functions).
|
||||
#
|
||||
# The data that you retrieve from the TMDb API is used to build your graph using the Graph class. After you build your graph using the
|
||||
# TMDb API data, use the Graph class write_edges_file & write_nodes_file methods to produce the separate nodes and edges
|
||||
# .csv files for submission to Gradescope.
|
||||
#
|
||||
# While building the co-actor graph, you will be required to write code to expand the graph by iterating
|
||||
# through a portion of the graph nodes and finding similar artists using the TMDb API. We will not grade this code directly
|
||||
# but will grade the resulting graph data in your nodes and edges .csv files.
|
||||
#
|
||||
#############################################################################################################################
|
||||
|
||||
|
||||
class Graph:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, with_nodes_file=None, with_edges_file=None):
|
||||
"""
|
||||
option 1: init as an empty graph and add nodes
|
||||
option 2: init by specifying a path to nodes & edges files
|
||||
"""
|
||||
self.nodes = []
|
||||
self.edges = []
|
||||
if with_nodes_file and with_edges_file:
|
||||
nodes_CSV = csv.reader(open(with_nodes_file))
|
||||
nodes_CSV = list(nodes_CSV)[1:]
|
||||
self.nodes = [(n[0], n[1]) for n in nodes_CSV]
|
||||
|
||||
edges_CSV = csv.reader(open(with_edges_file))
|
||||
edges_CSV = list(edges_CSV)[1:]
|
||||
self.edges = [(e[0], e[1]) for e in edges_CSV]
|
||||
|
||||
|
||||
def add_node(self, id: str, name: str) -> None:
|
||||
"""
|
||||
add a tuple (id, name) representing a node to self.nodes if it does not already exist
|
||||
The graph should not contain any duplicate nodes
|
||||
"""
|
||||
if (id, name) not in self.nodes:
|
||||
self.nodes.append((id, name))
|
||||
|
||||
|
||||
|
||||
def add_edge(self, source: str, target: str) -> None:
|
||||
"""
|
||||
Add an edge between two nodes if it does not already exist.
|
||||
An edge is represented by a tuple containing two strings: e.g.: ('source', 'target').
|
||||
Where 'source' is the id of the source node and 'target' is the id of the target node
|
||||
e.g., for two nodes with ids 'a' and 'b' respectively, add the tuple ('a', 'b') to self.edges
|
||||
"""
|
||||
current_edge = (source, target)
|
||||
current_edge_inverted = (target, source)
|
||||
if (source != target) and (current_edge not in self.edges) and (current_edge_inverted not in self.edges):
|
||||
self.edges.append(current_edge)
|
||||
|
||||
|
||||
|
||||
def total_nodes(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of nodes in the graph
|
||||
"""
|
||||
return len(self.nodes)
|
||||
|
||||
def total_edges(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of edges in the graph
|
||||
"""
|
||||
return len(self.edges)
|
||||
|
||||
def max_degree_nodes(self) -> dict:
|
||||
"""
|
||||
Return the node(s) with the highest degree
|
||||
Return multiple nodes in the event of a tie
|
||||
Format is a dict where the key is the node_id and the value is an integer for the node degree
|
||||
e.g. {'a': 8}
|
||||
or {'a': 22, 'b': 22}
|
||||
"""
|
||||
|
||||
max_degree_nodes = {}
|
||||
|
||||
for edge in self.edges:
|
||||
for idx in edge:
|
||||
if idx in max_degree_nodes:
|
||||
max_degree_nodes[idx] += 1
|
||||
else:
|
||||
max_degree_nodes[idx] = 1
|
||||
|
||||
v = list(max_degree_nodes.values())
|
||||
k = list(max_degree_nodes.keys())
|
||||
max_nodes = {k[v.index(max(v))]: max(v)}
|
||||
print(max_nodes)
|
||||
return max_nodes
|
||||
|
||||
def print_nodes(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.nodes)
|
||||
|
||||
|
||||
def print_edges(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.edges)
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_edges_file(self, path="edges_ref.csv")->None:
|
||||
"""
|
||||
write all edges out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
edges_path = path
|
||||
edges_file = open(edges_path, 'w', encoding='utf-8')
|
||||
|
||||
edges_file.write("source" + "," + "target" + "\n")
|
||||
|
||||
for e in self.edges:
|
||||
edges_file.write(e[0] + "," + e[1] + "\n")
|
||||
|
||||
edges_file.close()
|
||||
print("finished writing edges to csv")
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_nodes_file(self, path="nodes_ref.csv")->None:
|
||||
"""
|
||||
write all nodes out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
nodes_path = path
|
||||
nodes_file = open(nodes_path, 'w', encoding='utf-8')
|
||||
|
||||
nodes_file.write("id,name" + "\n")
|
||||
for n in self.nodes:
|
||||
nodes_file.write(n[0] + "," + n[1] + "\n")
|
||||
nodes_file.close()
|
||||
print("finished writing nodes to csv")
|
||||
|
||||
def non_leaf_nodes(self):
|
||||
nodes_degrees = {}
|
||||
for edge in self.edges:
|
||||
for idx in edge:
|
||||
if idx in nodes_degrees:
|
||||
nodes_degrees[idx] += 1
|
||||
else:
|
||||
nodes_degrees[idx] = 1
|
||||
|
||||
non_leaf_nodes = dict((k, v) for k, v in nodes_degrees.items() if v > 1)
|
||||
return len(non_leaf_nodes)
|
||||
|
||||
|
||||
class TMDBAPIUtils:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, api_key:str):
|
||||
self.api_key=api_key
|
||||
|
||||
|
||||
def get_movie_cast(self, movie_id:str, limit:int=None, exclude_ids:list=None) -> list:
|
||||
"""
|
||||
Get the movie cast for a given movie id, with optional parameters to exclude an cast member
|
||||
from being returned and/or to limit the number of returned cast members
|
||||
documentation url: https://developers.themoviedb.org/3/movies/get-movie-credits
|
||||
|
||||
:param string movie_id: a movie_id
|
||||
:param list exclude_ids: a list of ints containing ids (not cast_ids) of cast members that should be excluded from the returned result
|
||||
e.g., if exclude_ids are [353, 455] then exclude these from any result.
|
||||
:param integer limit: maximum number of returned cast members by their 'order' attribute
|
||||
e.g., limit=5 will attempt to return the 5 cast members having 'order' attribute values between 0-4
|
||||
If after excluding, there are fewer cast members than the specified limit, then return the remaining members (excluding the ones whose order values are outside the limit range).
|
||||
If cast members with 'order' attribute in the specified limit range have been excluded, do not include more cast members to reach the limit.
|
||||
If after excluding, the limit is not specified, then return all remaining cast members."
|
||||
e.g., if limit=5 and the actor whose id corresponds to cast member with order=1 is to be excluded,
|
||||
return cast members with order values [0, 2, 3, 4], not [0, 2, 3, 4, 5]
|
||||
:rtype: list
|
||||
return a list of dicts, one dict per cast member with the following structure:
|
||||
[{'id': '97909' # the id of the cast member
|
||||
'character': 'John Doe' # the name of the character played
|
||||
'credit_id': '52fe4249c3a36847f8012927' # id of the credit, ...}, ... ]
|
||||
Note that this is an example of the structure of the list and some of the fields returned by the API.
|
||||
The result of the API call will include many more fields for each cast member.
|
||||
"""
|
||||
|
||||
connection = http.client.HTTPSConnection('api.themoviedb.org')
|
||||
connection.request("GET", "/3/movie/{0}/credits?api_key={1}&language=en-US".format(movie_id, self.api_key))
|
||||
response = connection.getresponse()
|
||||
if response.status == 200:
|
||||
data = response.read()
|
||||
decoded_data = json.loads(data.decode('UTF-8'))
|
||||
cast = decoded_data['cast']
|
||||
if exclude_ids is not None:
|
||||
cast = [i for i in cast if i['id'] not in exclude_ids]
|
||||
print(cast)
|
||||
if limit is not None:
|
||||
cast = [i for i in cast if i['order'] < limit]
|
||||
print(cast)
|
||||
for c in cast:
|
||||
c['name'] = c['name'].replace(',', '')
|
||||
return cast
|
||||
else:
|
||||
print(response.status.__str__())
|
||||
return None
|
||||
|
||||
def get_movie_credits_for_person(self, person_id:str, vote_avg_threshold:float=None)->list:
|
||||
"""
|
||||
Using the TMDb API, get the movie credits for a person serving in a cast role
|
||||
documentation url: https://developers.themoviedb.org/3/people/get-person-movie-credits
|
||||
|
||||
:param string person_id: the id of a person
|
||||
:param vote_avg_threshold: optional parameter to return the movie credit if it is >=
|
||||
the specified threshold.
|
||||
e.g., if the vote_avg_threshold is 5.0, then only return credits with a vote_avg >= 5.0
|
||||
:rtype: list
|
||||
return a list of dicts, with each dict having 'id', 'title', and 'vote_avg' keys,
|
||||
one dict per movie credit with the following structure:
|
||||
[{'id': '97909' # the id of the movie
|
||||
'title': 'Long, Stock and Two Smoking Barrels' # the title (not original title) of the credit
|
||||
'vote_avg': 5.0 # the float value of the vote average value for the credit}, ... ]
|
||||
"""
|
||||
url = "https://api.themoviedb.org/3/person/9999/movie_credits?language=en-US&api_key=1eed362096d67d9f077084d5abb30a35"
|
||||
|
||||
connection = http.client.HTTPSConnection('api.themoviedb.org')
|
||||
connection.request("GET", "/3/person/{0}/movie_credits?api_key={1}&language=en-US".format(person_id, self.api_key))
|
||||
response = connection.getresponse()
|
||||
if response.status == 200:
|
||||
data = response.read()
|
||||
decoded_data = json.loads(data.decode('UTF-8'))
|
||||
raw_credits = decoded_data['cast']
|
||||
if vote_avg_threshold is not None:
|
||||
filtered_credits = [{"id":idx["id"], "title":idx["title"], "vote_avg":idx["vote_average"]} for idx in raw_credits if idx["vote_average"] >= vote_avg_threshold]
|
||||
print(filtered_credits)
|
||||
return filtered_credits
|
||||
else:
|
||||
unfiltered_credits = [{"id":idx["id"], "title":idx["title"], "vote_avg":idx["vote_average"]} for idx in raw_credits]
|
||||
print(unfiltered_credits)
|
||||
return unfiltered_credits
|
||||
else:
|
||||
print("ERROR: " + response.status.__str__())
|
||||
return None
|
||||
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
#
|
||||
# BUILDING YOUR GRAPH
|
||||
#
|
||||
# Working with the API: See use of http.request: https://docs.python.org/3/library/http.client.html#examples
|
||||
#
|
||||
# Using TMDb's API, build a co-actor network for the actor's/actress' highest rated movies
|
||||
# In this graph, each node represents an actor
|
||||
# An edge between any two nodes indicates that the two actors/actresses acted in a movie together
|
||||
# i.e., they share a movie credit.
|
||||
# e.g., An edge between Samuel L. Jackson and Robert Downey Jr. indicates that they have acted in one
|
||||
# or more movies together.
|
||||
#
|
||||
# For this assignment, we are interested in a co-actor network of highly rated movies; specifically,
|
||||
# we only want the top 3 co-actors in each movie credit of an actor having a vote average >= 8.0.
|
||||
# Build your co-actor graph on the actor 'Laurence Fishburne' w/ person_id 2975.
|
||||
#
|
||||
# You will need to add extra functions or code to accomplish this. We will not directly call or explicitly grade your
|
||||
# algorithm. We will instead measure the correctness of your output by evaluating the data in your nodes.csv and edges.csv files.
|
||||
#
|
||||
# GRAPH SIZE
|
||||
# With each iteration of your graph build, the number of nodes and edges grows approximately at an exponential rate.
|
||||
# Our testing indicates growth approximately equal to e^2x.
|
||||
# Since the TMDB API is a live database, the number of nodes / edges in the final graph will vary slightly depending on when
|
||||
# you execute your graph building code. We take this into account by rebuilding the solution graph every few days and
|
||||
# updating the auto-grader. We establish a bound for lowest & highest encountered numbers of nodes and edges with a
|
||||
# margin of +/- 100 for nodes and +/- 150 for edges. e.g., The allowable range of nodes is set to:
|
||||
#
|
||||
# Min allowable nodes = min encountered nodes - 100
|
||||
# Max allowable nodes = max allowable nodes + 100
|
||||
#
|
||||
# e.g., if the minimum encountered nodes = 507 and the max encountered nodes = 526, then the min/max range is 407-626
|
||||
# The same method is used to calculate the edges with the exception of using the aforementioned edge margin.
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
# BEGIN BUILD CO-ACTOR NETWORK
|
||||
#
|
||||
# INITIALIZE GRAPH
|
||||
# Initialize a Graph object with a single node representing Laurence Fishburne
|
||||
#
|
||||
# BEGIN BUILD BASE GRAPH:
|
||||
# Find all of Laurence Fishburne's movie credits that have a vote average >= 8.0
|
||||
# FOR each movie credit:
|
||||
# | get the movie cast members having an 'order' value between 0-2 (these are the co-actors)
|
||||
# |
|
||||
# | FOR each movie cast member:
|
||||
# | | using graph.add_node(), add the movie cast member as a node (keep track of all new nodes added to the graph)
|
||||
# | | using graph.add_edge(), add an edge between the Laurence Fishburne (actor) node
|
||||
# | | and each new node (co-actor/co-actress)
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END BUILD BASE GRAPH
|
||||
#
|
||||
#
|
||||
# BEGIN LOOP - DO 2 TIMES:
|
||||
# IF first iteration of loop:
|
||||
# | nodes = The nodes added in the BUILD BASE GRAPH (this excludes the original node of Laurence Fishburne!)
|
||||
# ELSE
|
||||
# | nodes = The nodes added in the previous iteration:
|
||||
# ENDIF
|
||||
#
|
||||
# FOR each node in nodes:
|
||||
# | get the movie credits for the actor that have a vote average >= 8.0
|
||||
# |
|
||||
# | FOR each movie credit:
|
||||
# | | try to get the 3 movie cast members having an 'order' value between 0-2
|
||||
# | |
|
||||
# | | FOR each movie cast member:
|
||||
# | | | IF the node doesn't already exist:
|
||||
# | | | | add the node to the graph (track all new nodes added to the graph)
|
||||
# | | | ENDIF
|
||||
# | | |
|
||||
# | | | IF the edge does not exist:
|
||||
# | | | | add an edge between the node (actor) and the new node (co-actor/co-actress)
|
||||
# | | | ENDIF
|
||||
# | | END FOR
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END LOOP
|
||||
#
|
||||
# Your graph should not have any duplicate edges or nodes
|
||||
# Write out your finished graph as a nodes file and an edges file using:
|
||||
# graph.write_edges_file()
|
||||
# graph.write_nodes_file()
|
||||
#
|
||||
# END BUILD CO-ACTOR NETWORK
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Exception handling and best practices
|
||||
# - You should use the param 'language=en-US' in all API calls to avoid encoding issues when writing data to file.
|
||||
# - If the actor name has a comma char ',' it should be removed to prevent extra columns from being inserted into the .csv file
|
||||
# - Some movie_credits do not return cast data. Handle this situation by skipping these instances.
|
||||
# - While The TMDb API does not have a rate-limiting scheme in place, consider that making hundreds / thousands of calls
|
||||
# can occasionally result in timeout errors. If you continue to experience 'ConnectionRefusedError : [Errno 61] Connection refused',
|
||||
# - wait a while and then try again. It may be necessary to insert periodic sleeps when you are building your graph.
|
||||
|
||||
|
||||
def return_name()->str:
|
||||
"""
|
||||
Return a string containing your GT Username
|
||||
e.g., tlou31
|
||||
Do not return your 9 digit GTId
|
||||
"""
|
||||
return "GT Username"
|
||||
|
||||
|
||||
# def return_argo_lite_snapshot()->str:
|
||||
# """
|
||||
# Return the shared URL of your published graph in Argo-Lite
|
||||
# """
|
||||
# return "https://poloclub.github.io/argo-graph-lite/#1ac32aec-ba9f-4693-83e1-cd4a7e81fb93"
|
||||
|
||||
|
||||
# You should modify __main__ as you see fit to build/test your graph using the TMDBAPIUtils & Graph classes.
|
||||
# Some boilerplate/sample code is provided for demonstration. We will not call __main__ during grading.
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
graph = Graph()
|
||||
graph.add_node(id='2975', name='Laurence Fishburne')
|
||||
|
||||
# build base graph
|
||||
# find all laurence fishburne's movie credits with a vote average >= 8.0
|
||||
tmdb_api_utils = TMDBAPIUtils(api_key='1eed362096d67d9f077084d5abb30a35')
|
||||
movie_credits = tmdb_api_utils.get_movie_credits_for_person(person_id='2975', vote_avg_threshold=8.0)
|
||||
print(len(movie_credits))
|
||||
print(movie_credits)
|
||||
|
||||
# for each movie credit get movie cast members having and order value between 0-2 (3 0-base)
|
||||
for movie in movie_credits:
|
||||
movie_cast = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for cast_member in movie_cast:
|
||||
graph.add_node(str(cast_member['id']), cast_member['name'])
|
||||
graph.add_edge(source='2975', target=str(cast_member['id']))
|
||||
break # TODO: remove me
|
||||
break # TODO: remove me
|
||||
|
||||
for i in [0,1,2]:
|
||||
print('ref loop '+ str(i))
|
||||
if i == 0:
|
||||
current_nodes = graph.nodes[1:]
|
||||
else:
|
||||
current_nodes = [i for i in graph.nodes if i not in current_nodes]
|
||||
|
||||
for node in current_nodes:
|
||||
cast = tmdb_api_utils.get_movie_credits_for_person(person_id=node[0], vote_avg_threshold=8.0)
|
||||
for movie in cast:
|
||||
actors = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for actor in actors:
|
||||
graph.add_node(str(actor['id']), actor['name'])
|
||||
graph.add_edge(str(node[0]), str(actor['id']))
|
||||
|
||||
|
||||
|
||||
# tmdb_api_utils.get_movie_cast(movie_id='100', limit=3, exclude_ids=[973, 974])
|
||||
# tmdb_api_utils.get_movie_credits_for_person(person_id="9709", vote_avg_threshold=5.0)
|
||||
|
||||
# call functions or place code here to build graph (graph building code not graded)
|
||||
# Suggestion: code should contain steps outlined above in BUILD CO-ACTOR NETWORK
|
||||
|
||||
print(f"Edges: {graph.total_edges()}")
|
||||
print(f"Nodes: {graph.total_nodes()}")
|
||||
|
||||
graph.write_edges_file()
|
||||
graph.write_nodes_file()
|
||||
|
||||
# If you have already built & written out your graph, you could read in your nodes & edges files
|
||||
# to perform testing on your graph.
|
||||
graph = Graph(with_edges_file="edges.csv", with_nodes_file="nodes.csv")
|
||||
|
||||
#get non-leaf nodes
|
||||
non_leaf = graph.non_leaf_nodes()
|
||||
print(non_leaf - 10)
|
||||
print("DONE")
|
418
tunmnlu/task_1/Q1/bundle-fix/Q1.py
Normal file
418
tunmnlu/task_1/Q1/bundle-fix/Q1.py
Normal file
@@ -0,0 +1,418 @@
|
||||
import http.client
|
||||
import json
|
||||
import csv
|
||||
import urllib.request
|
||||
import os,sys
|
||||
|
||||
#############################################################################################################################
|
||||
# cse6242
|
||||
# All instructions, code comments, etc. contained within this notebook are part of the assignment instructions.
|
||||
# Portions of this file will auto-graded in Gradescope using different sets of parameters / data to ensure that values are not
|
||||
# hard-coded.
|
||||
#
|
||||
# Instructions: Implement all methods in this file that have a return
|
||||
# value of 'NotImplemented'. See the documentation within each method for specific details, including
|
||||
# the expected return value
|
||||
#
|
||||
# Helper Functions:
|
||||
# You are permitted to write additional helper functions/methods or use additional instance variables within
|
||||
# the `Graph` class or `TMDbAPIUtils` class so long as the originally included methods work as required.
|
||||
#
|
||||
# Use:
|
||||
# The `Graph` class is used to represent and store the data for the TMDb co-actor network graph. This class must
|
||||
# also provide some basic analytics, i.e., number of nodes, edges, and nodes with the highest degree.
|
||||
#
|
||||
# The `TMDbAPIUtils` class is used to retrieve Actor/Movie data using themoviedb.org API. We have provided a few necessary methods
|
||||
# to test your code w/ the API, e.g.: get_movie_cast(), get_movie_credits_for_person(). You may add additional
|
||||
# methods and instance variables as desired (see Helper Functions).
|
||||
#
|
||||
# The data that you retrieve from the TMDb API is used to build your graph using the Graph class. After you build your graph using the
|
||||
# TMDb API data, use the Graph class write_edges_file & write_nodes_file methods to produce the separate nodes and edges
|
||||
# .csv files for submission to Gradescope.
|
||||
#
|
||||
# While building the co-actor graph, you will be required to write code to expand the graph by iterating
|
||||
# through a portion of the graph nodes and finding similar artists using the TMDb API. We will not grade this code directly
|
||||
# but will grade the resulting graph data in your nodes and edges .csv files.
|
||||
#
|
||||
#############################################################################################################################
|
||||
|
||||
|
||||
class Graph:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, with_nodes_file=None, with_edges_file=None):
|
||||
"""
|
||||
option 1: init as an empty graph and add nodes
|
||||
option 2: init by specifying a path to nodes & edges files
|
||||
"""
|
||||
self.nodes = []
|
||||
self.edges = []
|
||||
if with_nodes_file and with_edges_file:
|
||||
nodes_CSV = csv.reader(open(with_nodes_file))
|
||||
nodes_CSV = list(nodes_CSV)[1:]
|
||||
self.nodes = [(n[0], n[1]) for n in nodes_CSV]
|
||||
|
||||
edges_CSV = csv.reader(open(with_edges_file))
|
||||
edges_CSV = list(edges_CSV)[1:]
|
||||
self.edges = [(e[0], e[1]) for e in edges_CSV]
|
||||
|
||||
|
||||
def add_node(self, id: str, name: str) -> None:
|
||||
"""
|
||||
add a tuple (id, name) representing a node to self.nodes if it does not already exist
|
||||
The graph should not contain any duplicate nodes
|
||||
"""
|
||||
if (id, name) not in self.nodes:
|
||||
self.nodes.append((id, name))
|
||||
|
||||
|
||||
|
||||
def add_edge(self, source: str, target: str) -> None:
|
||||
"""
|
||||
Add an edge between two nodes if it does not already exist.
|
||||
An edge is represented by a tuple containing two strings: e.g.: ('source', 'target').
|
||||
Where 'source' is the id of the source node and 'target' is the id of the target node
|
||||
e.g., for two nodes with ids 'a' and 'b' respectively, add the tuple ('a', 'b') to self.edges
|
||||
"""
|
||||
current_edge = (source, target)
|
||||
current_edge_inverted = (target, source)
|
||||
if (source != target) and (current_edge not in self.edges) and (current_edge_inverted not in self.edges):
|
||||
self.edges.append(current_edge)
|
||||
|
||||
|
||||
|
||||
def total_nodes(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of nodes in the graph
|
||||
"""
|
||||
output = len(self.nodes)
|
||||
return output
|
||||
|
||||
def total_edges(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of edges in the graph
|
||||
"""
|
||||
output = len(self.edges)
|
||||
return output
|
||||
|
||||
def max_degree_nodes(self) -> dict:
|
||||
"""
|
||||
Return the node(s) with the highest degree
|
||||
Return multiple nodes in the event of a tie
|
||||
Format is a dict where the key is the node_id and the value is an integer for the node degree
|
||||
e.g. {'a': 8}
|
||||
or {'a': 22, 'b': 22}
|
||||
"""
|
||||
|
||||
max_degree_nodes = {}
|
||||
|
||||
for edge in self.edges:
|
||||
for idx in edge:
|
||||
if idx in max_degree_nodes:
|
||||
max_degree_nodes[idx] += 1
|
||||
else:
|
||||
max_degree_nodes[idx] = 1
|
||||
|
||||
v = list(max_degree_nodes.values())
|
||||
k = list(max_degree_nodes.keys())
|
||||
max_nodes = {k[v.index(max(v))]: max(v)}
|
||||
# print(max_nodes)
|
||||
return max_nodes
|
||||
|
||||
def print_nodes(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.nodes)
|
||||
|
||||
|
||||
def print_edges(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.edges)
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_edges_file(self, path="edges.csv")->None:
|
||||
"""
|
||||
write all edges out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
edges_path = path
|
||||
edges_file = open(edges_path, 'w', encoding='utf-8')
|
||||
|
||||
edges_file.write("source" + "," + "target" + "\n")
|
||||
|
||||
for e in self.edges:
|
||||
edges_file.write(e[0] + "," + e[1] + "\n")
|
||||
|
||||
edges_file.close()
|
||||
print("finished writing edges to csv")
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_nodes_file(self, path="nodes.csv")->None:
|
||||
"""
|
||||
write all nodes out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
nodes_path = path
|
||||
nodes_file = open(nodes_path, 'w', encoding='utf-8')
|
||||
|
||||
nodes_file.write("id,name" + "\n")
|
||||
for n in self.nodes:
|
||||
nodes_file.write(n[0] + "," + n[1] + "\n")
|
||||
nodes_file.close()
|
||||
print("finished writing nodes to csv")
|
||||
|
||||
|
||||
class TMDBAPIUtils:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, api_key:str):
|
||||
self.api_key=api_key
|
||||
|
||||
def get_movie_cast(self, movie_id:str, limit:int=None, exclude_ids:list=None) -> list:
|
||||
"""
|
||||
Get the movie cast for a given movie id, with optional parameters to exclude an cast member
|
||||
from being returned and/or to limit the number of returned cast members
|
||||
documentation url: https://developers.themoviedb.org/3/movies/get-movie-credits
|
||||
|
||||
:param string movie_id: a movie_id
|
||||
:param list exclude_ids: a list of ints containing ids (not cast_ids) of cast members that should be excluded from the returned result
|
||||
e.g., if exclude_ids are [353, 455] then exclude these from any result.
|
||||
:param integer limit: maximum number of returned cast members by their 'order' attribute
|
||||
e.g., limit=5 will attempt to return the 5 cast members having 'order' attribute values between 0-4
|
||||
If after excluding, there are fewer cast members than the specified limit, then return the remaining members (excluding the ones whose order values are outside the limit range).
|
||||
If cast members with 'order' attribute in the specified limit range have been excluded, do not include more cast members to reach the limit.
|
||||
If after excluding, the limit is not specified, then return all remaining cast members."
|
||||
e.g., if limit=5 and the actor whose id corresponds to cast member with order=1 is to be excluded,
|
||||
return cast members with order values [0, 2, 3, 4], not [0, 2, 3, 4, 5]
|
||||
:rtype: list
|
||||
return a list of dicts, one dict per cast member with the following structure:
|
||||
[{'id': '97909' # the id of the cast member
|
||||
'character': 'John Doe' # the name of the character played
|
||||
'credit_id': '52fe4249c3a36847f8012927' # id of the credit, ...}, ... ]
|
||||
Note that this is an example of the structure of the list and some of the fields returned by the API.
|
||||
The result of the API call will include many more fields for each cast member.
|
||||
"""
|
||||
|
||||
url = 'https://api.themoviedb.org/3/movie/'+ str(movie_id) +'/credits?api_key='+self.api_key +"&language=en-US"
|
||||
req = urllib.request.Request(url, headers={
|
||||
'Accept': 'application/json',
|
||||
})
|
||||
response = urllib.request.urlopen(req)
|
||||
if response.status == 200:
|
||||
json_data = json.load(response)
|
||||
cast = json_data['cast']
|
||||
if exclude_ids is not None:
|
||||
cast = [i for i in cast if i['id'] not in exclude_ids]
|
||||
# print(cast)
|
||||
if limit is not None:
|
||||
cast = [i for i in cast if i['order'] < limit]
|
||||
# print(cast)
|
||||
for c in cast:
|
||||
c['name'] = c['name'].replace(',', '')
|
||||
return cast
|
||||
else:
|
||||
print(response.status.__str__())
|
||||
return None
|
||||
|
||||
def get_movie_credits_for_person(self, person_id:str, vote_avg_threshold:float=None)->list:
|
||||
"""
|
||||
Using the TMDb API, get the movie credits for a person serving in a cast role
|
||||
documentation url: https://developers.themoviedb.org/3/people/get-person-movie-credits
|
||||
|
||||
:param string person_id: the id of a person
|
||||
:param vote_avg_threshold: optional parameter to return the movie credit if it is >=
|
||||
the specified threshold.
|
||||
e.g., if the vote_avg_threshold is 5.0, then only return credits with a vote_avg >= 5.0
|
||||
:rtype: list
|
||||
return a list of dicts, with each dict having 'id', 'title', and 'vote_avg' keys,
|
||||
one dict per movie credit with the following structure:
|
||||
[{'id': '97909' # the id of the movie
|
||||
'title': 'Long, Stock and Two Smoking Barrels' # the title (not original title) of the credit
|
||||
'vote_avg': 5.0 # the float value of the vote average value for the credit}, ... ]
|
||||
"""
|
||||
url = 'https://api.themoviedb.org/3/person/'+ str(person_id) +'/movie_credits?api_key='+self.api_key+'&language=en-US'
|
||||
req = urllib.request.Request(url, headers={
|
||||
'Accept': 'application/json',
|
||||
})
|
||||
response = urllib.request.urlopen(req)
|
||||
|
||||
if response.status == 200:
|
||||
raw_data = response.read()
|
||||
# refer to https://docs.python.org/3/library/json.html convert data to dictionary
|
||||
cast_data = (json.loads(raw_data.decode('utf-8'))).get("cast")
|
||||
# only include id which is above avg rating
|
||||
abv_avg = [data for data in cast_data if data.get('vote_average') >= vote_avg_threshold]
|
||||
|
||||
# else:
|
||||
# print(response.status, response.reason)
|
||||
return abv_avg
|
||||
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
#
|
||||
# BUILDING YOUR GRAPH
|
||||
#
|
||||
# Working with the API: See use of http.request: https://docs.python.org/3/library/http.client.html#examples
|
||||
#
|
||||
# Using TMDb's API, build a co-actor network for the actor's/actress' highest rated movies
|
||||
# In this graph, each node represents an actor
|
||||
# An edge between any two nodes indicates that the two actors/actresses acted in a movie together
|
||||
# i.e., they share a movie credit.
|
||||
# e.g., An edge between Samuel L. Jackson and Robert Downey Jr. indicates that they have acted in one
|
||||
# or more movies together.
|
||||
#
|
||||
# For this assignment, we are interested in a co-actor network of highly rated movies; specifically,
|
||||
# we only want the top 3 co-actors in each movie credit of an actor having a vote average >= 8.0.
|
||||
# Build your co-actor graph on the actor 'Laurence Fishburne' w/ person_id 2975.
|
||||
#
|
||||
# You will need to add extra functions or code to accomplish this. We will not directly call or explicitly grade your
|
||||
# algorithm. We will instead measure the correctness of your output by evaluating the data in your nodes.csv and edges.csv files.
|
||||
#
|
||||
# GRAPH SIZE
|
||||
# With each iteration of your graph build, the number of nodes and edges grows approximately at an exponential rate.
|
||||
# Our testing indicates growth approximately equal to e^2x.
|
||||
# Since the TMDB API is a live database, the number of nodes / edges in the final graph will vary slightly depending on when
|
||||
# you execute your graph building code. We take this into account by rebuilding the solution graph every few days and
|
||||
# updating the auto-grader. We establish a bound for lowest & highest encountered numbers of nodes and edges with a
|
||||
# margin of +/- 100 for nodes and +/- 150 for edges. e.g., The allowable range of nodes is set to:
|
||||
#
|
||||
# Min allowable nodes = min encountered nodes - 100
|
||||
# Max allowable nodes = max allowable nodes + 100
|
||||
#
|
||||
# e.g., if the minimum encountered nodes = 507 and the max encountered nodes = 526, then the min/max range is 407-626
|
||||
# The same method is used to calculate the edges with the exception of using the aforementioned edge margin.
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
# BEGIN BUILD CO-ACTOR NETWORK
|
||||
#
|
||||
# INITIALIZE GRAPH
|
||||
# Initialize a Graph object with a single node representing Laurence Fishburne
|
||||
#
|
||||
# BEGIN BUILD BASE GRAPH:
|
||||
# Find all of Laurence Fishburne's movie credits that have a vote average >= 8.0
|
||||
# FOR each movie credit:
|
||||
# | get the movie cast members having an 'order' value between 0-2 (these are the co-actors)
|
||||
# |
|
||||
# | FOR each movie cast member:
|
||||
# | | using graph.add_node(), add the movie cast member as a node (keep track of all new nodes added to the graph)
|
||||
# | | using graph.add_edge(), add an edge between the Laurence Fishburne (actor) node
|
||||
# | | and each new node (co-actor/co-actress)
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END BUILD BASE GRAPH
|
||||
#
|
||||
#
|
||||
# BEGIN LOOP - DO 2 TIMES:
|
||||
# IF first iteration of loop:
|
||||
# | nodes = The nodes added in the BUILD BASE GRAPH (this excludes the original node of Laurence Fishburne!)
|
||||
# ELSE
|
||||
# | nodes = The nodes added in the previous iteration:
|
||||
# ENDIF
|
||||
#
|
||||
# FOR each node in nodes:
|
||||
# | get the movie credits for the actor that have a vote average >= 8.0
|
||||
# |
|
||||
# | FOR each movie credit:
|
||||
# | | try to get the 3 movie cast members having an 'order' value between 0-2
|
||||
# | |
|
||||
# | | FOR each movie cast member:
|
||||
# | | | IF the node doesn't already exist:
|
||||
# | | | | add the node to the graph (track all new nodes added to the graph)
|
||||
# | | | ENDIF
|
||||
# | | |
|
||||
# | | | IF the edge does not exist:
|
||||
# | | | | add an edge between the node (actor) and the new node (co-actor/co-actress)
|
||||
# | | | ENDIF
|
||||
# | | END FOR
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END LOOP
|
||||
#
|
||||
# Your graph should not have any duplicate edges or nodes
|
||||
# Write out your finished graph as a nodes file and an edges file using:
|
||||
# graph.write_edges_file()
|
||||
# graph.write_nodes_file()
|
||||
#
|
||||
# END BUILD CO-ACTOR NETWORK
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Exception handling and best practices
|
||||
# - You should use the param 'language=en-US' in all API calls to avoid encoding issues when writing data to file.
|
||||
# - If the actor name has a comma char ',' it should be removed to prevent extra columns from being inserted into the .csv file
|
||||
# - Some movie_credits do not return cast data. Handle this situation by skipping these instances.
|
||||
# - While The TMDb API does not have a rate-limiting scheme in place, consider that making hundreds / thousands of calls
|
||||
# can occasionally result in timeout errors. If you continue to experience 'ConnectionRefusedError : [Errno 61] Connection refused',
|
||||
# - wait a while and then try again. It may be necessary to insert periodic sleeps when you are building your graph.
|
||||
|
||||
|
||||
def return_name()->str:
|
||||
"""
|
||||
Return a string containing your GT Username
|
||||
e.g., tlou31
|
||||
Do not return your 9 digit GTId
|
||||
"""
|
||||
return "tlou31"
|
||||
|
||||
# You should modify __main__ as you see fit to build/test your graph using the TMDBAPIUtils & Graph classes.
|
||||
# Some boilerplate/sample code is provided for demonstration. We will not call __main__ during grading.
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# init graph object with a single node representing laurence fishburne
|
||||
graph = Graph()
|
||||
graph.add_node(id='2975', name='Laurence Fishburne')
|
||||
|
||||
# build base graph
|
||||
# find all laurence fishburne's movie credits with a vote average >= 8.0
|
||||
tmdb_api_utils = TMDBAPIUtils(api_key='1eed362096d67d9f077084d5abb30a35')
|
||||
movie_credits = tmdb_api_utils.get_movie_credits_for_person(person_id='2975', vote_avg_threshold=8.0)
|
||||
|
||||
# for each movie credit get movie cast members having and order value between 0-2 (3 0-base)
|
||||
for movie in movie_credits:
|
||||
movie_cast = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for cast_member in movie_cast:
|
||||
graph.add_node(str(cast_member['id']), cast_member['name'])
|
||||
graph.add_edge(source='2975', target=str(cast_member['id']))
|
||||
|
||||
for i in range(2):
|
||||
print('running loop ' + str(i))
|
||||
if i == 0:
|
||||
current_nodes = graph.nodes[1:]
|
||||
else:
|
||||
current_nodes = [i for i in graph.nodes if i not in current_nodes]
|
||||
|
||||
for node in current_nodes:
|
||||
cast = tmdb_api_utils.get_movie_credits_for_person(person_id=node[0], vote_avg_threshold=8.0)
|
||||
for movie in cast:
|
||||
actors = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for actor in actors:
|
||||
graph.add_node(str(actor['id']), actor['name'])
|
||||
graph.add_edge(str(node[0]), str(actor['id']))
|
||||
|
||||
# tmdb_api_utils.get_movie_cast(movie_id='100', limit=3, exclude_ids=[973, 974])
|
||||
# tmdb_api_utils.get_movie_credits_for_person(person_id="9709", vote_avg_threshold=5.0)
|
||||
|
||||
# call functions or place code here to build graph (graph building code not graded)
|
||||
# Suggestion: code should contain steps outlined above in BUILD CO-ACTOR NETWORK
|
||||
|
||||
print("Edges: " + str(graph.total_edges()))
|
||||
print("Nodes: " + str(graph.total_nodes()))
|
||||
|
||||
graph.write_edges_file()
|
||||
graph.write_nodes_file()
|
||||
|
||||
# If you have already built & written out your graph, you could read in your nodes & edges files
|
||||
# to perform testing on your graph.
|
||||
graph = Graph(with_edges_file="edges.csv", with_nodes_file="nodes.csv")
|
||||
|
||||
print("DONE")
|
||||
|
1127
tunmnlu/task_1/Q1/bundle-fix/edges.csv
Normal file
1127
tunmnlu/task_1/Q1/bundle-fix/edges.csv
Normal file
File diff suppressed because it is too large
Load Diff
797
tunmnlu/task_1/Q1/bundle-fix/nodes.csv
Normal file
797
tunmnlu/task_1/Q1/bundle-fix/nodes.csv
Normal file
@@ -0,0 +1,797 @@
|
||||
id,name
|
||||
2975,Laurence Fishburne
|
||||
6384,Keanu Reeves
|
||||
530,Carrie-Anne Moss
|
||||
8349,Martin Sheen
|
||||
8351,Frederic Forrest
|
||||
8354,Albert Hall
|
||||
1107983,Martin Luther King Jr.
|
||||
52057,Obba Babatundé
|
||||
110380,Colin Powell
|
||||
18471,Anthony Anderson
|
||||
74611,Tracee Ellis Ross
|
||||
1407498,Marsai Martin
|
||||
1357063,Darrin Prescott
|
||||
40644,Chad Stahelski
|
||||
1779512,Jackson Spidell
|
||||
21127,Bobby Cannavale
|
||||
1692944,Heidi Schreck
|
||||
64,Gary Oldman
|
||||
1776,Francis Ford Coppola
|
||||
38803,Roman Coppola
|
||||
20215,Billy Campbell
|
||||
2130,Cary Elwes
|
||||
529,Guy Pearce
|
||||
532,Joe Pantoliano
|
||||
1278399,Joseph Steven
|
||||
1659326,Teresa Modnick
|
||||
26466,Caroline Kava
|
||||
18269,Brendan Fraser
|
||||
5606,Sissy Spacek
|
||||
5632,Jack Fisk
|
||||
1179102,Kathleen Kennedy
|
||||
11367,Bradley Whitford
|
||||
31028,Richard Schiff
|
||||
1397846,Craig Barron
|
||||
2166741,Robert A. Baum Jr.
|
||||
3266,Joe Mantegna
|
||||
36059,Joanna Pacula
|
||||
21010,Alexandra Hay
|
||||
101032,Rod McCary
|
||||
98569,Vincent Van Patten
|
||||
2080584,Ben Jorgensen
|
||||
103835,Jeff Monahan
|
||||
6717,James Marshall
|
||||
928944,Coleman Barks
|
||||
2022250,Robert Bly
|
||||
9979,Peter Coyote
|
||||
514,Jack Nicholson
|
||||
6193,Leonardo DiCaprio
|
||||
1892,Matt Damon
|
||||
2641,Martin Landau
|
||||
92029,Gabriel Bologna
|
||||
218506,Gretchen Becker
|
||||
2098136,Brian Becker
|
||||
2098137,Richard Becker
|
||||
2098138,Blase Bonpane
|
||||
181934,Al Sharpton
|
||||
496175,Carmelo Anthony
|
||||
1280183,Coretta Scott King
|
||||
1006651,John Lewis
|
||||
237876,Sarah-Jane Sauvegrain
|
||||
180659,Rosa Parks
|
||||
1165240,Jason Alan Carvell
|
||||
2787630,Valentin Zorin
|
||||
89289,Jesse Jackson
|
||||
2102583,Andrew Cohen
|
||||
73988,Lyndon B. Johnson
|
||||
21111,John F. Kennedy
|
||||
2803017,Arthur John Birch
|
||||
2803001,Haroldson Lafayette Hunt
|
||||
4193575,Maxime Demigné
|
||||
4193577,Gabin Clerc
|
||||
4193578,Tom Chabeau
|
||||
2954,Jeffrey Wright
|
||||
33663,Donald Trump
|
||||
2301996,Mike Pence
|
||||
214317,Ben Bradlee
|
||||
13716,Carl Bernstein
|
||||
117180,Tom Brokaw
|
||||
23626,Liev Schreiber
|
||||
937663,Neil Amdur
|
||||
1931175,Bob Beamon
|
||||
12951,O.J. Simpson
|
||||
2998183,Nicole Brown Simpson
|
||||
1231277,Marcia Clark
|
||||
60158,Shirley Jones
|
||||
24810,Pat Boone
|
||||
2535,Vivica A. Fox
|
||||
225620,Rudolph Moise
|
||||
1683093,Terayle Hill
|
||||
79538,Khalil Kain
|
||||
1562353,Erica Mena
|
||||
1038,Jodie Foster
|
||||
4173,Anthony Hopkins
|
||||
349,Scott Glenn
|
||||
4587,Halle Berry
|
||||
9780,Angela Bassett
|
||||
19011,George W. Bush
|
||||
146687,Tony Blair
|
||||
74266,Dick Cheney
|
||||
1507609,Bob Coen
|
||||
1507612,Francis E. Boyle
|
||||
1507613,Jean Patterson
|
||||
1122373,Marion Barry Jr.
|
||||
1122374,Chuck Brown
|
||||
1122375,Lewis Franklin
|
||||
1897,Bernie Mac
|
||||
77896,Bill Bellamy
|
||||
2395,Whoopi Goldberg
|
||||
1735828,Halle Bailey
|
||||
53397,Christina Aguilera
|
||||
1224841,Mo Willems
|
||||
539,Thomas Lennon
|
||||
111513,Yvette Nicole Brown
|
||||
2682390,Gerd Ludwig
|
||||
2227,Nicole Kidman
|
||||
4430,Sharon Stone
|
||||
14837,Carol Burnett
|
||||
5823,Julie Andrews
|
||||
3141,Marisa Tomei
|
||||
449538,Adele
|
||||
13309,Oprah Winfrey
|
||||
1661465,Lizzo
|
||||
102786,Barack Obama
|
||||
128550,Desmond Tutu
|
||||
2320880,Sundar Pichai
|
||||
3894,Christian Bale
|
||||
19498,Jon Bernthal
|
||||
2710,James Cameron
|
||||
8691,Zoe Saldaña
|
||||
72129,Jennifer Lawrence
|
||||
189111,Suzanne Collins
|
||||
23964,Gary Ross
|
||||
9827,Rose Byrne
|
||||
143103,Krew Boylan
|
||||
21708,Tomas Milian
|
||||
72983,Manny Pérez
|
||||
124909,Danny Hoch
|
||||
4038,Susan Sarandon
|
||||
18992,Aidan Quinn
|
||||
2047,Danny Glover
|
||||
4730,Emmy Rossum
|
||||
9464,Harry Lennix
|
||||
14409,David Schwimmer
|
||||
1415341,Kazuhiro Tsuji
|
||||
1267653,Chet Zar
|
||||
7467,David Fincher
|
||||
1519399,Erik Messerschmidt
|
||||
1003,Jean Reno
|
||||
524,Natalie Portman
|
||||
1810,Heath Ledger
|
||||
3895,Michael Caine
|
||||
958722,Eiko Ishioka
|
||||
41381,Sadie Frost
|
||||
10980,Daniel Radcliffe
|
||||
10989,Rupert Grint
|
||||
10990,Emma Watson
|
||||
219479,Criss Angel
|
||||
1101349,Steve Aoki
|
||||
1407495,Miles Brown
|
||||
3361135,Peter Kent
|
||||
1812,Michelle Williams
|
||||
2037,Cillian Murphy
|
||||
5081,Emily Blunt
|
||||
2559324,Beth Lane
|
||||
2559325,Lea Madda
|
||||
27888,Raúl Juliá
|
||||
2630,Nastassja Kinski
|
||||
151007,Peter Ramsey
|
||||
1769,Sofia Coppola
|
||||
19772,Paul Rassam
|
||||
1,George Lucas
|
||||
7879,John Lasseter
|
||||
1032,Martin Scorsese
|
||||
1006721,Charles Scorsese
|
||||
11483,Catherine Scorsese
|
||||
5953,Spike Jonze
|
||||
325,Eminem
|
||||
3125,Madonna
|
||||
3084,Marlon Brando
|
||||
1158,Al Pacino
|
||||
3085,James Caan
|
||||
3087,Robert Duvall
|
||||
3092,Diane Keaton
|
||||
117669,Portia Doubleday
|
||||
558466,Alex Russell
|
||||
61555,Haley Ramm
|
||||
10017,Charlton Heston
|
||||
5563,James Coburn
|
||||
26557,Ferdy Mayne
|
||||
18688,Harry Connick Jr.
|
||||
8437,Teri Garr
|
||||
589,Daryl Hannah
|
||||
16431,Sam Elliott
|
||||
2203,Neal McDonough
|
||||
3026,Rob Reiner
|
||||
32,Robin Wright
|
||||
12132,Michael Rooker
|
||||
932719,Jeff Gordon
|
||||
2127,James Wan
|
||||
2128,Leigh Whannell
|
||||
2675,Darren Lynn Bousman
|
||||
46300,Alexander Nathan Etel
|
||||
27889,Stephan Elliott
|
||||
1331,Hugo Weaving
|
||||
326,Kim Basinger
|
||||
323,Curtis Hanson
|
||||
11099,Dante Spinotti
|
||||
7187,Richard Donner
|
||||
57371,Jeff Cohen
|
||||
3034,Corey Feldman
|
||||
147,Michael Madsen
|
||||
21200,Will Arnett
|
||||
13611,Jack White
|
||||
10750,Sheryl Crow
|
||||
8261,Willie Nelson
|
||||
54693,Emma Stone
|
||||
19492,Viola Davis
|
||||
6944,Octavia Spencer
|
||||
287,Brad Pitt
|
||||
192,Morgan Freeman
|
||||
12052,Gwyneth Paltrow
|
||||
5376,Jean Smart
|
||||
5937,Kari Matchett
|
||||
26009,Gail O'Grady
|
||||
1067583,Suzanne Happ
|
||||
10427,Anne Archer
|
||||
781,Paul Reiser
|
||||
33,Gary Sinise
|
||||
5149,Bonnie Hunt
|
||||
2144,Tobin Bell
|
||||
141,David Carradine
|
||||
2505,James Cromwell
|
||||
42206,Matt McCoy
|
||||
10167,George Lazenby
|
||||
1226195,Rob Stewart
|
||||
13637,Joan Collins
|
||||
5320,Leslie Caron
|
||||
1641,Katrin Cartlidge
|
||||
10447,Mariel Hemingway
|
||||
76184,Bryan Marshall
|
||||
75781,John Turner
|
||||
39770,Adam Roarke
|
||||
34721,Larry Bishop
|
||||
83908,Daniel Massey
|
||||
1748,William Shatner
|
||||
8499,William Windom
|
||||
16896,James Garner
|
||||
8857,Debbie Reynolds
|
||||
15395,Maurice Ronet
|
||||
51763,Ross Martin
|
||||
955923,Ginny Tyler
|
||||
6474,James Le Gros
|
||||
69122,Heather Graham
|
||||
65344,Esai Morales
|
||||
6677,Kyle MacLachlan
|
||||
6678,Michael Ontkean
|
||||
6714,Mädchen Amick
|
||||
56890,Malcolm McDowell
|
||||
46393,Roseanne Barr
|
||||
9789,Robert Altman
|
||||
6449,Warren Beatty
|
||||
1353815,Dr. Diane Ravitch
|
||||
1353816,Dr. Linda Darling-Hammond
|
||||
20212,Dermot Mulroney
|
||||
41249,Tess Harper
|
||||
1841281,Joey Molland
|
||||
1225302,Annie Nightingale
|
||||
3546502,Jack Trout
|
||||
118764,Paulo Pires
|
||||
36281,Imanol Arias
|
||||
3199207,Jerry Dealey
|
||||
3199208,Barry Ernest
|
||||
82128,Wesley Clark
|
||||
21818,Lesley Ann Warren
|
||||
12967,Swoosie Kurtz
|
||||
13567,Ann-Margret
|
||||
25834,Leslie Hope
|
||||
1204293,J. Allen Hynek
|
||||
2027993,Philip J. Klass
|
||||
20959,Louis Gossett Jr.
|
||||
57829,Anthony LaPaglia
|
||||
7447,Alec Baldwin
|
||||
9560,Ellen Burstyn
|
||||
37421,James Naughton
|
||||
9976,Henry Thomas
|
||||
69597,Drew Barrymore
|
||||
1066777,Mumia Abu-Jamal
|
||||
65013,Rubin 'Hurricane' Carter
|
||||
4808,Giancarlo Esposito
|
||||
2045089,Jeanmarie Simpson
|
||||
4687,Patricia Arquette
|
||||
2045090,Joyce Julianne Auer
|
||||
60642,Tom Petty
|
||||
22865,Little Richard
|
||||
13301,Quincy Jones
|
||||
7071,Louise Fletcher
|
||||
518,Danny DeVito
|
||||
10409,Shelley Duvall
|
||||
7077,Scatman Crothers
|
||||
3391,Kathleen Turner
|
||||
117075,Henry Jaglom
|
||||
34947,Kevin Conroy
|
||||
1262612,Neal Adams
|
||||
103,Mark Ruffalo
|
||||
2282,Ben Kingsley
|
||||
24045,Joseph Gordon-Levitt
|
||||
3899,Ken Watanabe
|
||||
21007,Jonah Hill
|
||||
234352,Margot Robbie
|
||||
16418,Casey Kasem
|
||||
15831,Frank Welker
|
||||
134,Jamie Foxx
|
||||
27319,Christoph Waltz
|
||||
11478,Lorraine Bracco
|
||||
380,Robert De Niro
|
||||
9261,Frank Abagnale Jr.
|
||||
488,Steven Spielberg
|
||||
2689,Jeff Nathanson
|
||||
31,Tom Hanks
|
||||
1206,Jason Alexander
|
||||
70851,Jack Black
|
||||
2157,Robin Williams
|
||||
880,Ben Affleck
|
||||
1231844,Manny Ramírez
|
||||
1214256,Curt Schilling
|
||||
3197,Tom Sizemore
|
||||
12833,Edward Burns
|
||||
10297,Matthew McConaughey
|
||||
1813,Anne Hathaway
|
||||
83002,Jessica Chastain
|
||||
21037,Prince
|
||||
1800494,Cora Coleman-Dunham
|
||||
1775343,Josh Dunham
|
||||
1205143,John Gazarian
|
||||
1205144,Darlene Landau
|
||||
2222,Beau Bridges
|
||||
18878,Rob Cohen
|
||||
9111,Peter Graves
|
||||
98234,Barbara Bain
|
||||
24589,Paul Mercurio
|
||||
24590,Dominique Sanda
|
||||
11770,John Carpenter
|
||||
515,Glenn Close
|
||||
229579,Bob Carruthers
|
||||
220717,Uri Geller
|
||||
1229925,La Toya Jackson
|
||||
179512,Marv Albert
|
||||
1865991,Jim Boeheim
|
||||
59785,Fat Joe
|
||||
84932,Jay-Z
|
||||
16450,Sean Combs
|
||||
210695,Jesse Williams
|
||||
1258041,David Axelrod
|
||||
1236577,Douglas Brinkley
|
||||
1374664,Louis-Émile Galey
|
||||
1010125,Claude Heymann
|
||||
1385039,Bryan Stevenson
|
||||
1641150,Patrisse Cullors
|
||||
938972,Angela Davis
|
||||
2149806,Gus Hall
|
||||
100709,Junior Wells
|
||||
1386798,Joseph McCarthy
|
||||
13348,Howard Hughes
|
||||
1247141,Harry S. Truman
|
||||
2802990,Jean Paul Getty
|
||||
117418,Mahalia Jackson
|
||||
1188876,Horace Clarence Boyer
|
||||
61399,Mike Ditka
|
||||
1232728,Jim McMahon
|
||||
1723195,Mike Singletary
|
||||
1219050,Hank Aaron
|
||||
14414,Kareem Abdul-Jabbar
|
||||
65605,Muhammad Ali
|
||||
136403,Robert Dryden
|
||||
1999091,Chris Schenkel
|
||||
1050881,Jacqueline Kennedy
|
||||
1152,Oliver Stone
|
||||
3331792,Vasili Arkhipov
|
||||
120578,Franklin D. Roosevelt
|
||||
57738,Samuel Labarthe
|
||||
1141815,Charles de Gaulle
|
||||
1204877,André Malraux
|
||||
1257876,Margaret Whitmer
|
||||
1051824,Tom Junod
|
||||
1998031,Joanne Rogers
|
||||
1116399,Winston Churchill
|
||||
18802,Ronald Reagan
|
||||
7571,Blair Brown
|
||||
84378,Nick Fraser
|
||||
1420,Robert Drew
|
||||
2102600,Jill Drew
|
||||
225009,Pablo Larraín
|
||||
6431,Darren Aronofsky
|
||||
8289,Billy Crudup
|
||||
1670479,Abbas Abdi
|
||||
1625013,Mahmoud Ahmadinejad
|
||||
84384,Osama Bin Laden
|
||||
2214123,Véronique Préault
|
||||
2412677,Xavier Pasco
|
||||
2412679,John Logsdon
|
||||
16811,Alexander Scheer
|
||||
3910768,Jürgen Hambrecht
|
||||
2823180,Wolfgang Ischinger
|
||||
4193580,Tkun
|
||||
4193583,Sofiane
|
||||
25072,Oscar Isaac
|
||||
3910,Frances McDormand
|
||||
1241,John Turturro
|
||||
1145892,Ed Koch
|
||||
1807640,Jane Jacobs
|
||||
557911,Robert F. Kennedy Jr.
|
||||
11161,Tom Savini
|
||||
27765,Richard Nixon
|
||||
1167702,Bruno Sammartino
|
||||
1167703,Bob Backlund
|
||||
2323039,Catherine Mercado-Muñiz
|
||||
2339577,Carmen Yulín Cruz
|
||||
10127,Jon Voight
|
||||
1229169,Roger Ailes
|
||||
3553309,John Shipton
|
||||
150882,Julian Assange
|
||||
16214,Mario Van Peebles
|
||||
227811,Herschel Walker
|
||||
1222706,Skip Bayless
|
||||
1816204,Frederick Oberlander
|
||||
1816207,Tevfik Arif
|
||||
3342345,Tim Gielen
|
||||
1954181,George Soros
|
||||
240633,Bill Gates
|
||||
80757,Mike Tyson
|
||||
1003978,Larry Holmes
|
||||
1306642,Kimberly DiPersia
|
||||
2289540,Alex R. Wagner
|
||||
2662043,Andrew Cuomo
|
||||
2266228,Kim Dae-jung
|
||||
2435679,Lee Geum-hee
|
||||
2266230,Kim Young-sam
|
||||
56446,John Cena
|
||||
216075,Candice Michelle
|
||||
568535,Matthew Kaye
|
||||
1326321,Paige
|
||||
57342,Vince McMahon
|
||||
60342,Emily Maitlis
|
||||
2041195,Prince Andrew Duke of York
|
||||
2607708,Jeffrey Epstein
|
||||
16620,Hulk Hogan
|
||||
77120,Steve Austin
|
||||
1647876,Hans Henrik Wöhler
|
||||
3252749,Michael Fanone
|
||||
3370866,Aquilino Gonell
|
||||
28151,Benoît Allemane
|
||||
2982422,Michael S. Cullen
|
||||
3242458,Isabelle Rouge-Ducos
|
||||
21397,Dennis Rodman
|
||||
3981237,Shirley Rodman
|
||||
567335,Chris Benoit
|
||||
115788,Paul Michael Lévesque
|
||||
112219,Michael Hickenbottom
|
||||
25504,André Roussimoff
|
||||
160733,Nick Bockwinkel
|
||||
2189100,Moon Jae-in
|
||||
1671675,Yuna Kim
|
||||
1644623,Ahn Jung-hwan
|
||||
21278,Alan Alda
|
||||
13724,Jane Alexander
|
||||
1428889,Ivy Austin
|
||||
3323316,Tricia Brooks
|
||||
2021450,Vernon Jordan
|
||||
3797418,Maria Kirke
|
||||
937664,Abraham Beame
|
||||
937665,Bob Bright
|
||||
1416398,Joshua L. Pearson
|
||||
46432,George H.W. Bush
|
||||
116341,Bill Clinton
|
||||
2652100,Curt Flood
|
||||
2652101,Judy Pace Flood
|
||||
219189,Jackie Robinson
|
||||
214725,Duke Snider
|
||||
3905,William H. Macy
|
||||
18686,Holly Hunter
|
||||
223120,Jack O'Callahan
|
||||
223121,Herb Brooks
|
||||
223122,Mike Eruzione
|
||||
107375,Joe Frazier
|
||||
1304153,Imelda Marcos
|
||||
587506,Shameik Moore
|
||||
543505,Jake Johnson
|
||||
130640,Hailee Steinfeld
|
||||
2415973,Daniel Petrocelli
|
||||
2413592,Fred Goldman
|
||||
81439,Vincent Bugliosi
|
||||
707,Dan Aykroyd
|
||||
26485,Jim Belushi
|
||||
54812,Chevy Chase
|
||||
5788,James Cagney
|
||||
87514,Roger Smith
|
||||
2177,Lloyd Bridges
|
||||
11140,Lynn Carlin
|
||||
1503749,Big Freedia
|
||||
1430,Keith Richards
|
||||
562922,Christian Keyes
|
||||
21215,Elise Neal
|
||||
21563,Corin Nemec
|
||||
2939038,Sydney Malakeh
|
||||
8689,Barry Shabaka Henley
|
||||
2297056,Darik Bernard
|
||||
2295,Mickey Rourke
|
||||
141823,Tisha Campbell
|
||||
1841650,Crystal-Lee Naomi
|
||||
1838518,Jermaine Rivers
|
||||
58924,Clifton Powell
|
||||
21355,DMX
|
||||
1922617,Joy Rovaris
|
||||
587035,Nadji Jeter
|
||||
479206,Demetria McKinney
|
||||
154382,Jazsmin Lewis
|
||||
31134,Darrin Henson
|
||||
74613,Terri J. Vaughn
|
||||
2808544,Daran Acevedo
|
||||
1297171,Julian Bane
|
||||
108081,Malik Barnhardt
|
||||
1220781,Shelly Altman
|
||||
115002,John Aniston
|
||||
1395884,Gessica Généus
|
||||
105762,Jimmy Jean-Louis
|
||||
1142232,Soledad Elizabeth Jean
|
||||
7672,Reginald VelJohnson
|
||||
1432244,Lyon Beckwith
|
||||
127931,Dorien Wilson
|
||||
77353,Jasmine Guy
|
||||
233191,Terrence 'T.C.' Carson
|
||||
1108907,Nick Robinson
|
||||
9278,Jennifer Garner
|
||||
19536,Josh Duhamel
|
||||
3593345,Chara James
|
||||
3593347,Zebulen M.N. Joyner-McCaster
|
||||
1214197,Carl Anthony Payne II
|
||||
16897,Sidney Poitier
|
||||
20493,Sydney Tamiia Poitier
|
||||
119598,Phylicia Rashād
|
||||
109686,Flex Alexander
|
||||
109687,Mike Batayeh
|
||||
77072,Tyson Beckford
|
||||
1232383,Parker McKenna Posey
|
||||
1573627,Torrei Hart
|
||||
1437841,AzMarie Livingston
|
||||
55637,Brian Hooks
|
||||
1100816,René Aranda
|
||||
3581413,Dwight Boyce
|
||||
60490,Paul Terrell Clayton
|
||||
1036,Cybill Shepherd
|
||||
5049,John Hurt
|
||||
10774,Anne Bancroft
|
||||
39187,Olivia Colman
|
||||
34546,Mark Gatiss
|
||||
54448,Ismail Merchant
|
||||
54441,James Ivory
|
||||
54443,Ruth Prawer Jhabvala
|
||||
4786,Richard Attenborough
|
||||
1137,Juliette Binoche
|
||||
28974,Damon Lindelof
|
||||
15851,Amy Brenneman
|
||||
15009,Justin Theroux
|
||||
33181,Jimmy Smits
|
||||
63611,Nickolas Grace
|
||||
53574,Eric Thal
|
||||
16217,Lynn Whitfield
|
||||
15762,Tara Strong
|
||||
1160,Michelle Pfeiffer
|
||||
8891,John Travolta
|
||||
44038,Nancy Allen
|
||||
1121437,Leslie Felperin
|
||||
70243,Eartha Kitt
|
||||
15973,Julie Newmar
|
||||
16108,Lee Meriwether
|
||||
44796,Franklyn Ajaye
|
||||
35705,Regina Hall
|
||||
143242,Terrence Jenkins
|
||||
174837,Yolanda Adams
|
||||
56323,Tina Fey
|
||||
78577,Graham Norton
|
||||
3223,Robert Downey Jr.
|
||||
16828,Chris Evans
|
||||
1189929,Condoleezza Rice
|
||||
7904,Billy Crystal
|
||||
533195,Henry Kissinger
|
||||
143280,Norman Mailer
|
||||
2801284,Anthony Amsterdam
|
||||
1220601,John Chancellor
|
||||
1066763,Darrell Royal
|
||||
50707,Ed Marinaro
|
||||
1322033,Bob Brenly
|
||||
1322034,Scott Brosius
|
||||
1233313,Joe Buck
|
||||
3273875,Bob Taylor
|
||||
3622690,Betty Ong
|
||||
3622691,Nydia Gonzalez
|
||||
3492377,Madeleine Albright
|
||||
3492379,Ilie Alexandru
|
||||
3492380,Ioan Amarie
|
||||
1442410,Trevor Phillips
|
||||
1442411,Nigel Farage
|
||||
1225259,Kirsty Young
|
||||
174981,King Charles III of the United Kingdom
|
||||
1094687,Prince Edward Duke of Edinburgh
|
||||
1306064,Princess Diana of Wales
|
||||
558240,Queen Elizabeth II of the United Kingdom
|
||||
47,Björk
|
||||
3219627,Lydia Korniordou
|
||||
2921077,Jacques Rogge
|
||||
37759,Kathy Burke
|
||||
20056,Keith Allen
|
||||
2330903,Amir Amor
|
||||
3897137,Cool 'Disco' Dan
|
||||
9290,Henry Rollins
|
||||
15535,Robin Harris
|
||||
5726,Cedric the Entertainer
|
||||
68215,Reginald Hudlin
|
||||
181975,Mark Curry
|
||||
82587,Steve Harvey
|
||||
78029,Martin Lawrence
|
||||
9309,Richard Pryor
|
||||
57551,Mario Cantone
|
||||
18291,Larenz Tate
|
||||
1633946,Chris Gattling
|
||||
10814,Wesley Snipes
|
||||
1903010,Spence Moore II
|
||||
55638,Kevin Hart
|
||||
5916,Rosario Dawson
|
||||
9206,Neve Campbell
|
||||
36811,Nick Cannon
|
||||
1870421,Collie Buddz
|
||||
2412016,Lilly Bartlam
|
||||
186529,Tony Daniels
|
||||
88059,Tommy Davidson
|
||||
15411,T.K. Carter
|
||||
1428,Mick Jagger
|
||||
1429,Charlie Watts
|
||||
53396,Ron Wood
|
||||
8534,Kathy Bates
|
||||
1121,Benicio del Toro
|
||||
3392,Michael Douglas
|
||||
17051,James Franco
|
||||
59315,Olivia Wilde
|
||||
2838,Chloë Sevigny
|
||||
155488,Kelly Clarkson
|
||||
292445,Blake Shelton
|
||||
21986,Reba McEntire
|
||||
2387,Patrick Stewart
|
||||
2388,Jonathan Frakes
|
||||
1213786,Brent Spiner
|
||||
4756,Matthew Broderick
|
||||
15152,James Earl Jones
|
||||
16940,Jeremy Irons
|
||||
148120,Tiffany
|
||||
83170,Valerie Harper
|
||||
2774840,Luis Miranda
|
||||
1179651,Lin-Manuel Miranda
|
||||
216674,Hillary Clinton
|
||||
73641,Christiane Amanpour
|
||||
1202593,Neil Barnard
|
||||
33684,Bono
|
||||
1650331,Jeremy O. Harris
|
||||
350,Laura Linney
|
||||
2391,Michael Dorn
|
||||
172069,Chadwick Boseman
|
||||
1215522,Robin Roberts
|
||||
1896,Don Cheadle
|
||||
6240,Mariska Hargitay
|
||||
21411,Ice-T
|
||||
206637,Kelli Giddish
|
||||
120608,Sonia Manzano
|
||||
1596910,Nitya Vidyasagar
|
||||
934281,Alex Wolff
|
||||
1700685,Lewis Pullman
|
||||
1241339,Bo Mitchell
|
||||
14386,Beyoncé
|
||||
1214573,Serena Williams
|
||||
93527,Kelly Rowland
|
||||
167662,Ryan Seacrest
|
||||
2384929,Lindsay Arnold
|
||||
138986,Tony Bennett
|
||||
72208,Alicia Keys
|
||||
3284,Bruce Springsteen
|
||||
18746,Stevie Wonder
|
||||
37934,André 3000
|
||||
15310,Anthony Kiedis
|
||||
12207,Kylie Minogue
|
||||
1564846,Auli'i Cravalho
|
||||
1473281,James Monroe Iglehart
|
||||
2522829,Vanessa Laine Bryant
|
||||
23678,Michael Jordan
|
||||
35806,Shaquille O'Neal
|
||||
1212304,Jon Scieszka
|
||||
1192274,Jordan Fisher
|
||||
132354,Kate Micucci
|
||||
133451,Aya Cash
|
||||
111684,Lennon Parham
|
||||
60227,Greg Cipes
|
||||
1249820,Romi Dames
|
||||
8536,Victor Garber
|
||||
1178795,Ben Diskin
|
||||
1842039,Joe Tessitore
|
||||
71403,Rob Riggle
|
||||
129193,Paula Abdul
|
||||
75394,Terence Donovan
|
||||
1083951,Veronica Lang
|
||||
500,Tom Cruise
|
||||
150536,Barry Otto
|
||||
76182,Nicholas Eadie
|
||||
76788,Dev Patel
|
||||
108916,Rooney Mara
|
||||
1371,David Wenham
|
||||
113552,Briony Behets
|
||||
1242514,James Smillie
|
||||
1246450,Bartholomew John
|
||||
1747292,Robert Board
|
||||
106179,Anthony Franciosa
|
||||
82315,Jean Harlow
|
||||
11492,Clark Gable
|
||||
1916574,Caitlin Doughty
|
||||
5168,Gabriel Byrne
|
||||
516,Annette Bening
|
||||
4517,Joe Pesci
|
||||
71531,Deepak Chopra
|
||||
1383964,Thích Nhất Hạnh
|
||||
1867979,Sister Chân Không
|
||||
8293,Marion Cotillard
|
||||
32017,Didier Lavergne
|
||||
3753843,Bryna Rifkin
|
||||
5682,Anouk Aimée
|
||||
44556,Richard Anconina
|
||||
20234,Fanny Ardant
|
||||
40159,Keith Michell
|
||||
58414,Dina Merrill
|
||||
4,Carrie Fisher
|
||||
6541,Philip Bosco
|
||||
157359,Jane Connell
|
||||
1729824,Randy Doney
|
||||
1392152,Dan Levy
|
||||
26510,Eugene Levy
|
||||
11514,Catherine O'Hara
|
||||
290,Christopher Plummer
|
||||
21104,Glenne Headly
|
||||
80866,Nell Carter
|
||||
40063,Lea DeLaria
|
||||
537064,Perry Como
|
||||
109887,Caroll Spinney
|
||||
8515,Jane Darwell
|
||||
5829,Karen Dotrice
|
||||
1201,Garry Marshall
|
||||
1041410,Charmian Carr
|
||||
22384,John Amos
|
||||
105637,Morey Amsterdam
|
||||
6613,Minnie Driver
|
||||
57133,Paulo Costanzo
|
||||
18461,Nick Chinlund
|
||||
1216139,Michael Raynor
|
||||
57389,Justin Pierce
|
||||
87525,Alan Carr
|
||||
7056,Emma Thompson
|
||||
154782,Pat Benatar
|
||||
154783,Neil Giraldo
|
||||
174875,Carly Simon
|
||||
929825,Ava DuVernay
|
||||
2302408,Korey Wise
|
||||
20019,Lee Daniels
|
||||
1658802,Andra Day
|
||||
964843,Michelle Obama
|
||||
3889844,Haizel Adofo
|
||||
113461,John Legend
|
||||
206444,Constance Wu
|
||||
1700631,Liza Koshy
|
||||
2503684,Abdullah bin Abdulaziz Al Saud
|
||||
107379,LeBron James
|
||||
66620,Angela Merkel
|
||||
2134341,Theresa May
|
||||
3089883,Gabby Giffords
|
||||
1608713,Mark Kelly
|
||||
1068409,Frank Marshall Davis
|
||||
1068410,Ann Dunham
|
||||
1068411,Stanley Dunham
|
||||
149923,Lester Brown
|
||||
1063969,Yvo de Boer
|
||||
1063970,Paul R. Ehrlich
|
||||
10279,Adolf Hitler
|
||||
89300,Nelson Mandela
|
||||
3451053,Natalya Sindeeva
|
||||
3527796,Aleksandr Vinokurov
|
||||
1745467,Vera Krichevskaya
|
||||
1173480,François Hollande
|
||||
1348088,Laurent Delahousse
|
||||
1977908,Claire Chazal
|
||||
2169865,Birgitta Assheuer
|
||||
2920376,Îlham Ahmed
|
||||
2920377,Zaher al-Saket
|
|
433
tunmnlu/task_1/Q1/bundle/Q1.py
Normal file
433
tunmnlu/task_1/Q1/bundle/Q1.py
Normal file
@@ -0,0 +1,433 @@
|
||||
import http.client
|
||||
import json
|
||||
import csv
|
||||
import urllib.request
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
# cse6242
|
||||
# All instructions, code comments, etc. contained within this notebook are part of the assignment instructions.
|
||||
# Portions of this file will auto-graded in Gradescope using different sets of parameters / data to ensure that values are not
|
||||
# hard-coded.
|
||||
#
|
||||
# Instructions: Implement all methods in this file that have a return
|
||||
# value of 'NotImplemented'. See the documentation within each method for specific details, including
|
||||
# the expected return value
|
||||
#
|
||||
# Helper Functions:
|
||||
# You are permitted to write additional helper functions/methods or use additional instance variables within
|
||||
# the `Graph` class or `TMDbAPIUtils` class so long as the originally included methods work as required.
|
||||
#
|
||||
# Use:
|
||||
# The `Graph` class is used to represent and store the data for the TMDb co-actor network graph. This class must
|
||||
# also provide some basic analytics, i.e., number of nodes, edges, and nodes with the highest degree.
|
||||
#
|
||||
# The `TMDbAPIUtils` class is used to retrieve Actor/Movie data using themoviedb.org API. We have provided a few necessary methods
|
||||
# to test your code w/ the API, e.g.: get_movie_cast(), get_movie_credits_for_person(). You may add additional
|
||||
# methods and instance variables as desired (see Helper Functions).
|
||||
#
|
||||
# The data that you retrieve from the TMDb API is used to build your graph using the Graph class. After you build your graph using the
|
||||
# TMDb API data, use the Graph class write_edges_file & write_nodes_file methods to produce the separate nodes and edges
|
||||
# .csv files for submission to Gradescope.
|
||||
#
|
||||
# While building the co-actor graph, you will be required to write code to expand the graph by iterating
|
||||
# through a portion of the graph nodes and finding similar artists using the TMDb API. We will not grade this code directly
|
||||
# but will grade the resulting graph data in your nodes and edges .csv files.
|
||||
#
|
||||
#############################################################################################################################
|
||||
|
||||
|
||||
class Graph:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, with_nodes_file=None, with_edges_file=None):
|
||||
"""
|
||||
option 1: init as an empty graph and add nodes
|
||||
option 2: init by specifying a path to nodes & edges files
|
||||
"""
|
||||
self.nodes = []
|
||||
self.edges = []
|
||||
if with_nodes_file and with_edges_file:
|
||||
nodes_CSV = csv.reader(open(with_nodes_file))
|
||||
nodes_CSV = list(nodes_CSV)[1:]
|
||||
self.nodes = [(n[0], n[1]) for n in nodes_CSV]
|
||||
|
||||
edges_CSV = csv.reader(open(with_edges_file))
|
||||
edges_CSV = list(edges_CSV)[1:]
|
||||
self.edges = [(e[0], e[1]) for e in edges_CSV]
|
||||
|
||||
|
||||
def add_node(self, id: str, name: str) -> None:
|
||||
"""
|
||||
add a tuple (id, name) representing a node to self.nodes if it does not already exist
|
||||
The graph should not contain any duplicate nodes
|
||||
"""
|
||||
if (id, name) not in self.nodes:
|
||||
self.nodes.append((id, name))
|
||||
|
||||
|
||||
|
||||
def add_edge(self, source: str, target: str) -> None:
|
||||
"""
|
||||
Add an edge between two nodes if it does not already exist.
|
||||
An edge is represented by a tuple containing two strings: e.g.: ('source', 'target').
|
||||
Where 'source' is the id of the source node and 'target' is the id of the target node
|
||||
e.g., for two nodes with ids 'a' and 'b' respectively, add the tuple ('a', 'b') to self.edges
|
||||
"""
|
||||
current_edge = (source, target)
|
||||
current_edge_inverted = (target, source)
|
||||
if (source != target) and (current_edge not in self.edges) and (current_edge_inverted not in self.edges):
|
||||
self.edges.append(current_edge)
|
||||
|
||||
|
||||
|
||||
def total_nodes(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of nodes in the graph
|
||||
"""
|
||||
output = len(self.nodes)
|
||||
return output
|
||||
|
||||
def total_edges(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of edges in the graph
|
||||
"""
|
||||
output = len(self.edges)
|
||||
return output
|
||||
|
||||
def max_degree_nodes(self) -> dict:
|
||||
"""
|
||||
Return the node(s) with the highest degree
|
||||
Return multiple nodes in the event of a tie
|
||||
Format is a dict where the key is the node_id and the value is an integer for the node degree
|
||||
e.g. {'a': 8}
|
||||
or {'a': 22, 'b': 22}
|
||||
"""
|
||||
|
||||
max_degree_nodes = {}
|
||||
|
||||
for edge in self.edges:
|
||||
for idx in edge:
|
||||
if idx in max_degree_nodes:
|
||||
max_degree_nodes[idx] += 1
|
||||
else:
|
||||
max_degree_nodes[idx] = 1
|
||||
|
||||
v = list(max_degree_nodes.values())
|
||||
k = list(max_degree_nodes.keys())
|
||||
max_nodes = {k[v.index(max(v))]: max(v)}
|
||||
return max_nodes
|
||||
|
||||
def print_nodes(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.nodes)
|
||||
|
||||
|
||||
def print_edges(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.edges)
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_edges_file(self, path="edges.csv")->None:
|
||||
"""
|
||||
write all edges out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
edges_path = path
|
||||
edges_file = open(edges_path, 'w', encoding='utf-8')
|
||||
|
||||
edges_file.write("source" + "," + "target" + "\n")
|
||||
|
||||
for e in self.edges:
|
||||
edges_file.write(e[0] + "," + e[1] + "\n")
|
||||
|
||||
edges_file.close()
|
||||
print("finished writing edges to csv")
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_nodes_file(self, path="nodes.csv")->None:
|
||||
"""
|
||||
write all nodes out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
nodes_path = path
|
||||
nodes_file = open(nodes_path, 'w', encoding='utf-8')
|
||||
|
||||
nodes_file.write("id,name" + "\n")
|
||||
for n in self.nodes:
|
||||
nodes_file.write(n[0] + "," + n[1] + "\n")
|
||||
nodes_file.close()
|
||||
print("finished writing nodes to csv")
|
||||
|
||||
|
||||
|
||||
class TMDBAPIUtils:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, api_key:str):
|
||||
self.api_key=api_key
|
||||
|
||||
|
||||
def get_movie_cast(self, movie_id:str, limit:int=None, exclude_ids:list=None) -> list:
|
||||
"""
|
||||
Get the movie cast for a given movie id, with optional parameters to exclude an cast member
|
||||
from being returned and/or to limit the number of returned cast members
|
||||
documentation url: https://developers.themoviedb.org/3/movies/get-movie-credits
|
||||
|
||||
:param string movie_id: a movie_id
|
||||
:param list exclude_ids: a list of ints containing ids (not cast_ids) of cast members that should be excluded from the returned result
|
||||
e.g., if exclude_ids are [353, 455] then exclude these from any result.
|
||||
:param integer limit: maximum number of returned cast members by their 'order' attribute
|
||||
e.g., limit=5 will attempt to return the 5 cast members having 'order' attribute values between 0-4
|
||||
If after excluding, there are fewer cast members than the specified limit, then return the remaining members (excluding the ones whose order values are outside the limit range).
|
||||
If cast members with 'order' attribute in the specified limit range have been excluded, do not include more cast members to reach the limit.
|
||||
If after excluding, the limit is not specified, then return all remaining cast members."
|
||||
e.g., if limit=5 and the actor whose id corresponds to cast member with order=1 is to be excluded,
|
||||
return cast members with order values [0, 2, 3, 4], not [0, 2, 3, 4, 5]
|
||||
:rtype: list
|
||||
return a list of dicts, one dict per cast member with the following structure:
|
||||
[{'id': '97909' # the id of the cast member
|
||||
'character': 'John Doe' # the name of the character played
|
||||
'credit_id': '52fe4249c3a36847f8012927' # id of the credit, ...}, ... ]
|
||||
Note that this is an example of the structure of the list and some of the fields returned by the API.
|
||||
The result of the API call will include many more fields for each cast member.
|
||||
"""
|
||||
|
||||
url = 'https://api.themoviedb.org/3/movie/'+ str(movie_id) +'/credits?api_key='+self.api_key +"&language=en-US"
|
||||
req = urllib.request.Request(url, headers={
|
||||
'Accept': 'application/json',
|
||||
})
|
||||
response = urllib.request.urlopen(req)
|
||||
if response.status == 200:
|
||||
json_data = json.load(response)
|
||||
cast = json_data['cast']
|
||||
if exclude_ids is not None:
|
||||
cast = [i for i in cast if i['id'] not in exclude_ids]
|
||||
# print(cast)
|
||||
if limit is not None:
|
||||
cast = [i for i in cast if i['order'] < limit]
|
||||
# print(cast)
|
||||
for c in cast:
|
||||
c['name'] = c['name'].replace(',', '')
|
||||
return cast
|
||||
else:
|
||||
print(response.status.__str__())
|
||||
return None
|
||||
|
||||
def get_movie_credits_for_person(self, person_id:str, vote_avg_threshold:float=None)->list:
|
||||
"""
|
||||
Using the TMDb API, get the movie credits for a person serving in a cast role
|
||||
documentation url: https://developers.themoviedb.org/3/people/get-person-movie-credits
|
||||
|
||||
:param string person_id: the id of a person
|
||||
:param vote_avg_threshold: optional parameter to return the movie credit if it is >=
|
||||
the specified threshold.
|
||||
e.g., if the vote_avg_threshold is 5.0, then only return credits with a vote_avg >= 5.0
|
||||
:rtype: list
|
||||
return a list of dicts, with each dict having 'id', 'title', and 'vote_avg' keys,
|
||||
one dict per movie credit with the following structure:
|
||||
[{'id': '97909' # the id of the movie
|
||||
'title': 'Long, Stock and Two Smoking Barrels' # the title (not original title) of the credit
|
||||
'vote_avg': 5.0 # the float value of the vote average value for the credit}, ... ]
|
||||
"""
|
||||
url = 'https://api.themoviedb.org/3/person/'+ str(person_id) +'/movie_credits?api_key='+self.api_key+'&language=en-US'
|
||||
req = urllib.request.Request(url, headers={
|
||||
'Accept': 'application/json',
|
||||
})
|
||||
response = urllib.request.urlopen(req)
|
||||
|
||||
if response.status == 200:
|
||||
json_data = json.load(response)
|
||||
raw_credits = json_data['cast']
|
||||
if vote_avg_threshold is not None:
|
||||
filtered_credits = []
|
||||
for idx in raw_credits:
|
||||
if idx["vote_average"] >= vote_avg_threshold:
|
||||
filtered_credits.append({
|
||||
"id":idx["id"],
|
||||
"title":idx["title"],
|
||||
"vote_avg":idx["vote_average"]
|
||||
})
|
||||
return filtered_credits
|
||||
else:
|
||||
unfiltered_credits = []
|
||||
for idx in raw_credits:
|
||||
unfiltered_credits.append({
|
||||
"id":idx["id"],
|
||||
"title":idx["title"],
|
||||
"vote_avg":idx["vote_average"]
|
||||
})
|
||||
return unfiltered_credits
|
||||
else:
|
||||
print("ERROR: " + response.status.__str__())
|
||||
return None
|
||||
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
#
|
||||
# BUILDING YOUR GRAPH
|
||||
#
|
||||
# Working with the API: See use of http.request: https://docs.python.org/3/library/http.client.html#examples
|
||||
#
|
||||
# Using TMDb's API, build a co-actor network for the actor's/actress' highest rated movies
|
||||
# In this graph, each node represents an actor
|
||||
# An edge between any two nodes indicates that the two actors/actresses acted in a movie together
|
||||
# i.e., they share a movie credit.
|
||||
# e.g., An edge between Samuel L. Jackson and Robert Downey Jr. indicates that they have acted in one
|
||||
# or more movies together.
|
||||
#
|
||||
# For this assignment, we are interested in a co-actor network of highly rated movies; specifically,
|
||||
# we only want the top 3 co-actors in each movie credit of an actor having a vote average >= 8.0.
|
||||
# Build your co-actor graph on the actor 'Laurence Fishburne' w/ person_id 2975.
|
||||
#
|
||||
# You will need to add extra functions or code to accomplish this. We will not directly call or explicitly grade your
|
||||
# algorithm. We will instead measure the correctness of your output by evaluating the data in your nodes.csv and edges.csv files.
|
||||
#
|
||||
# GRAPH SIZE
|
||||
# With each iteration of your graph build, the number of nodes and edges grows approximately at an exponential rate.
|
||||
# Our testing indicates growth approximately equal to e^2x.
|
||||
# Since the TMDB API is a live database, the number of nodes / edges in the final graph will vary slightly depending on when
|
||||
# you execute your graph building code. We take this into account by rebuilding the solution graph every few days and
|
||||
# updating the auto-grader. We establish a bound for lowest & highest encountered numbers of nodes and edges with a
|
||||
# margin of +/- 100 for nodes and +/- 150 for edges. e.g., The allowable range of nodes is set to:
|
||||
#
|
||||
# Min allowable nodes = min encountered nodes - 100
|
||||
# Max allowable nodes = max allowable nodes + 100
|
||||
#
|
||||
# e.g., if the minimum encountered nodes = 507 and the max encountered nodes = 526, then the min/max range is 407-626
|
||||
# The same method is used to calculate the edges with the exception of using the aforementioned edge margin.
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
# BEGIN BUILD CO-ACTOR NETWORK
|
||||
#
|
||||
# INITIALIZE GRAPH
|
||||
# Initialize a Graph object with a single node representing Laurence Fishburne
|
||||
#
|
||||
# BEGIN BUILD BASE GRAPH:
|
||||
# Find all of Laurence Fishburne's movie credits that have a vote average >= 8.0
|
||||
# FOR each movie credit:
|
||||
# | get the movie cast members having an 'order' value between 0-2 (these are the co-actors)
|
||||
# |
|
||||
# | FOR each movie cast member:
|
||||
# | | using graph.add_node(), add the movie cast member as a node (keep track of all new nodes added to the graph)
|
||||
# | | using graph.add_edge(), add an edge between the Laurence Fishburne (actor) node
|
||||
# | | and each new node (co-actor/co-actress)
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END BUILD BASE GRAPH
|
||||
#
|
||||
#
|
||||
# BEGIN LOOP - DO 2 TIMES:
|
||||
# IF first iteration of loop:
|
||||
# | nodes = The nodes added in the BUILD BASE GRAPH (this excludes the original node of Laurence Fishburne!)
|
||||
# ELSE
|
||||
# | nodes = The nodes added in the previous iteration:
|
||||
# ENDIF
|
||||
#
|
||||
# FOR each node in nodes:
|
||||
# | get the movie credits for the actor that have a vote average >= 8.0
|
||||
# |
|
||||
# | FOR each movie credit:
|
||||
# | | try to get the 3 movie cast members having an 'order' value between 0-2
|
||||
# | |
|
||||
# | | FOR each movie cast member:
|
||||
# | | | IF the node doesn't already exist:
|
||||
# | | | | add the node to the graph (track all new nodes added to the graph)
|
||||
# | | | ENDIF
|
||||
# | | |
|
||||
# | | | IF the edge does not exist:
|
||||
# | | | | add an edge between the node (actor) and the new node (co-actor/co-actress)
|
||||
# | | | ENDIF
|
||||
# | | END FOR
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END LOOP
|
||||
#
|
||||
# Your graph should not have any duplicate edges or nodes
|
||||
# Write out your finished graph as a nodes file and an edges file using:
|
||||
# graph.write_edges_file()
|
||||
# graph.write_nodes_file()
|
||||
#
|
||||
# END BUILD CO-ACTOR NETWORK
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Exception handling and best practices
|
||||
# - You should use the param 'language=en-US' in all API calls to avoid encoding issues when writing data to file.
|
||||
# - If the actor name has a comma char ',' it should be removed to prevent extra columns from being inserted into the .csv file
|
||||
# - Some movie_credits do not return cast data. Handle this situation by skipping these instances.
|
||||
# - While The TMDb API does not have a rate-limiting scheme in place, consider that making hundreds / thousands of calls
|
||||
# can occasionally result in timeout errors. If you continue to experience 'ConnectionRefusedError : [Errno 61] Connection refused',
|
||||
# - wait a while and then try again. It may be necessary to insert periodic sleeps when you are building your graph.
|
||||
|
||||
|
||||
def return_name()->str:
|
||||
"""
|
||||
Return a string containing your GT Username
|
||||
e.g., tlou31
|
||||
Do not return your 9 digit GTId
|
||||
"""
|
||||
return "tlou31"
|
||||
|
||||
# You should modify __main__ as you see fit to build/test your graph using the TMDBAPIUtils & Graph classes.
|
||||
# Some boilerplate/sample code is provided for demonstration. We will not call __main__ during grading.
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
graph = Graph()
|
||||
graph.add_node(id='2975', name='Laurence Fishburne')
|
||||
|
||||
# build base graph
|
||||
# find all laurence fishburne's movie credits with a vote average >= 8.0
|
||||
tmdb_api_utils = TMDBAPIUtils(api_key='1eed362096d67d9f077084d5abb30a35')
|
||||
movie_credits = tmdb_api_utils.get_movie_credits_for_person(person_id='2975', vote_avg_threshold=8.0)
|
||||
|
||||
# for each movie credit get movie cast members having and order value between 0-2 (3 0-base)
|
||||
for movie in movie_credits:
|
||||
movie_cast = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for cast_member in movie_cast:
|
||||
graph.add_node(str(cast_member['id']), cast_member['name'])
|
||||
graph.add_edge(source='2975', target=str(cast_member['id']))
|
||||
break
|
||||
break
|
||||
|
||||
for i in range(2):
|
||||
print('running loop ' + str(i))
|
||||
if i == 0:
|
||||
current_nodes = graph.nodes[1:]
|
||||
else:
|
||||
current_nodes = [i for i in graph.nodes if i not in current_nodes]
|
||||
|
||||
for node in current_nodes:
|
||||
cast = tmdb_api_utils.get_movie_credits_for_person(person_id=node[0], vote_avg_threshold=8.0)
|
||||
for movie in cast:
|
||||
actors = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for actor in actors:
|
||||
graph.add_node(str(actor['id']), actor['name'])
|
||||
graph.add_edge(str(node[0]), str(actor['id']))
|
||||
|
||||
# tmdb_api_utils.get_movie_cast(movie_id='100', limit=3, exclude_ids=[973, 974])
|
||||
# tmdb_api_utils.get_movie_credits_for_person(person_id="9709", vote_avg_threshold=5.0)
|
||||
|
||||
# call functions or place code here to build graph (graph building code not graded)
|
||||
# Suggestion: code should contain steps outlined above in BUILD CO-ACTOR NETWORK
|
||||
|
||||
print(f"Edges: {graph.total_edges()}")
|
||||
print(f"Nodes: {graph.total_nodes()}")
|
||||
|
||||
graph.write_edges_file()
|
||||
graph.write_nodes_file()
|
||||
|
||||
# If you have already built & written out your graph, you could read in your nodes & edges files
|
||||
# to perform testing on your graph.
|
||||
graph = Graph(with_edges_file="edges.csv", with_nodes_file="nodes.csv")
|
||||
print(graph.max_degree_nodes())
|
BIN
tunmnlu/task_1/Q1/bundle/Q1_problem.jpg
(Stored with Git LFS)
Normal file
BIN
tunmnlu/task_1/Q1/bundle/Q1_problem.jpg
(Stored with Git LFS)
Normal file
Binary file not shown.
123
tunmnlu/task_1/Q1/bundle/edges.csv
Normal file
123
tunmnlu/task_1/Q1/bundle/edges.csv
Normal file
@@ -0,0 +1,123 @@
|
||||
source,target
|
||||
2975,6384
|
||||
6384,530
|
||||
6384,1357063
|
||||
6384,40644
|
||||
6384,1779512
|
||||
6384,21127
|
||||
6384,1692944
|
||||
6384,64
|
||||
6384,1776
|
||||
6384,38803
|
||||
6384,20215
|
||||
6384,2130
|
||||
2975,530
|
||||
2975,8349
|
||||
2975,8351
|
||||
2975,8354
|
||||
2975,1107983
|
||||
2975,52057
|
||||
2975,110380
|
||||
2975,18471
|
||||
2975,74611
|
||||
2975,1407498
|
||||
530,529
|
||||
530,532
|
||||
1357063,40644
|
||||
1357063,3894
|
||||
1357063,1892
|
||||
1357063,19498
|
||||
40644,1779512
|
||||
40644,2710
|
||||
40644,4587
|
||||
40644,8691
|
||||
40644,72129
|
||||
40644,189111
|
||||
40644,23964
|
||||
1779512,1357063
|
||||
21127,1692944
|
||||
21127,9827
|
||||
21127,143103
|
||||
21127,21708
|
||||
21127,72983
|
||||
21127,124909
|
||||
21127,4038
|
||||
21127,18992
|
||||
21127,2047
|
||||
21127,4730
|
||||
21127,9464
|
||||
21127,14409
|
||||
64,1776
|
||||
64,1415341
|
||||
64,1267653
|
||||
64,7467
|
||||
64,1519399
|
||||
64,1003
|
||||
64,524
|
||||
64,38803
|
||||
64,3894
|
||||
64,1810
|
||||
64,3895
|
||||
64,958722
|
||||
64,41381
|
||||
64,10980
|
||||
64,10989
|
||||
64,10990
|
||||
64,20215
|
||||
64,2130
|
||||
64,219479
|
||||
64,1101349
|
||||
64,1407495
|
||||
64,3361135
|
||||
64,1812
|
||||
64,2037
|
||||
64,5081
|
||||
64,1892
|
||||
1776,2559324
|
||||
1776,2559325
|
||||
1776,27888
|
||||
1776,2630
|
||||
1776,958722
|
||||
1776,41381
|
||||
1776,38803
|
||||
1776,151007
|
||||
1776,1769
|
||||
1776,19772
|
||||
1776,1
|
||||
1776,7879
|
||||
1776,20215
|
||||
1776,2130
|
||||
1776,1032
|
||||
1776,1006721
|
||||
1776,11483
|
||||
1776,8349
|
||||
1776,8351
|
||||
1776,8354
|
||||
38803,151007
|
||||
38803,5953
|
||||
38803,325
|
||||
38803,3125
|
||||
38803,3084
|
||||
38803,1158
|
||||
38803,3085
|
||||
38803,3087
|
||||
38803,3092
|
||||
20215,2130
|
||||
20215,117669
|
||||
20215,558466
|
||||
20215,61555
|
||||
20215,10017
|
||||
20215,5563
|
||||
20215,26557
|
||||
20215,18688
|
||||
20215,8437
|
||||
20215,589
|
||||
2130,16431
|
||||
2130,2203
|
||||
2130,3026
|
||||
2130,32
|
||||
2130,12132
|
||||
2130,932719
|
||||
2130,2127
|
||||
2130,2128
|
||||
2130,2675
|
|
103
tunmnlu/task_1/Q1/bundle/nodes.csv
Normal file
103
tunmnlu/task_1/Q1/bundle/nodes.csv
Normal file
@@ -0,0 +1,103 @@
|
||||
id,name
|
||||
2975,Laurence Fishburne
|
||||
6384,Keanu Reeves
|
||||
530,Carrie-Anne Moss
|
||||
1357063,Darrin Prescott
|
||||
40644,Chad Stahelski
|
||||
1779512,Jackson Spidell
|
||||
21127,Bobby Cannavale
|
||||
1692944,Heidi Schreck
|
||||
64,Gary Oldman
|
||||
1776,Francis Ford Coppola
|
||||
38803,Roman Coppola
|
||||
20215,Billy Campbell
|
||||
2130,Cary Elwes
|
||||
8349,Martin Sheen
|
||||
8351,Frederic Forrest
|
||||
8354,Albert Hall
|
||||
1107983,Martin Luther King Jr.
|
||||
52057,Obba Babatundé
|
||||
110380,Colin Powell
|
||||
18471,Anthony Anderson
|
||||
74611,Tracee Ellis Ross
|
||||
1407498,Marsai Martin
|
||||
529,Guy Pearce
|
||||
532,Joe Pantoliano
|
||||
3894,Christian Bale
|
||||
1892,Matt Damon
|
||||
19498,Jon Bernthal
|
||||
2710,James Cameron
|
||||
4587,Halle Berry
|
||||
8691,Zoe Saldaña
|
||||
72129,Jennifer Lawrence
|
||||
189111,Suzanne Collins
|
||||
23964,Gary Ross
|
||||
9827,Rose Byrne
|
||||
143103,Krew Boylan
|
||||
21708,Tomas Milian
|
||||
72983,Manny Pérez
|
||||
124909,Danny Hoch
|
||||
4038,Susan Sarandon
|
||||
18992,Aidan Quinn
|
||||
2047,Danny Glover
|
||||
4730,Emmy Rossum
|
||||
9464,Harry Lennix
|
||||
14409,David Schwimmer
|
||||
1415341,Kazuhiro Tsuji
|
||||
1267653,Chet Zar
|
||||
7467,David Fincher
|
||||
1519399,Erik Messerschmidt
|
||||
1003,Jean Reno
|
||||
524,Natalie Portman
|
||||
1810,Heath Ledger
|
||||
3895,Michael Caine
|
||||
958722,Eiko Ishioka
|
||||
41381,Sadie Frost
|
||||
10980,Daniel Radcliffe
|
||||
10989,Rupert Grint
|
||||
10990,Emma Watson
|
||||
219479,Criss Angel
|
||||
1101349,Steve Aoki
|
||||
1407495,Miles Brown
|
||||
3361135,Peter Kent
|
||||
1812,Michelle Williams
|
||||
2037,Cillian Murphy
|
||||
5081,Emily Blunt
|
||||
2559324,Beth Lane
|
||||
2559325,Lea Madda
|
||||
27888,Raúl Juliá
|
||||
2630,Nastassja Kinski
|
||||
151007,Peter Ramsey
|
||||
1769,Sofia Coppola
|
||||
19772,Paul Rassam
|
||||
1,George Lucas
|
||||
7879,John Lasseter
|
||||
1032,Martin Scorsese
|
||||
1006721,Charles Scorsese
|
||||
11483,Catherine Scorsese
|
||||
5953,Spike Jonze
|
||||
325,Eminem
|
||||
3125,Madonna
|
||||
3084,Marlon Brando
|
||||
1158,Al Pacino
|
||||
3085,James Caan
|
||||
3087,Robert Duvall
|
||||
3092,Diane Keaton
|
||||
117669,Portia Doubleday
|
||||
558466,Alex Russell
|
||||
61555,Haley Ramm
|
||||
10017,Charlton Heston
|
||||
5563,James Coburn
|
||||
26557,Ferdy Mayne
|
||||
18688,Harry Connick Jr.
|
||||
8437,Teri Garr
|
||||
589,Daryl Hannah
|
||||
16431,Sam Elliott
|
||||
2203,Neal McDonough
|
||||
3026,Rob Reiner
|
||||
32,Robin Wright
|
||||
12132,Michael Rooker
|
||||
932719,Jeff Gordon
|
||||
2127,James Wan
|
||||
2128,Leigh Whannell
|
||||
2675,Darren Lynn Bousman
|
|
22
tunmnlu/task_1/Q1/bundle/test.sh
Normal file
22
tunmnlu/task_1/Q1/bundle/test.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
rm -rf *.csv
|
||||
|
||||
python ./Q1.py
|
||||
|
||||
# mv edges.csv edges_try1.csv
|
||||
# mv nodes.csv nodes_try1.csv
|
||||
|
||||
# python ./Q1.py
|
||||
|
||||
# mv edges.csv edges_try2.csv
|
||||
# mv nodes.csv nodes_try2.csv
|
||||
|
||||
# python ./Q1.py
|
||||
|
||||
# mv edges.csv edges_try3.csv
|
||||
# mv nodes.csv nodes_try3.csv
|
||||
|
||||
wc -l *.csv
|
10
tunmnlu/task_1/Q1/bundle/test_edge.py
Normal file
10
tunmnlu/task_1/Q1/bundle/test_edge.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import os,sys
|
||||
|
||||
test = []
|
||||
temp = ""
|
||||
with open('./edges.csv','r') as fi:
|
||||
test = list(map(lambda x: x.strip(), fi.readlines()))
|
||||
test = test[1:]
|
||||
|
||||
print(len(test))
|
||||
print(len(set(test)))
|
7
tunmnlu/task_1/Q1/docker-compose.yml
Normal file
7
tunmnlu/task_1/Q1/docker-compose.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
services:
|
||||
test:
|
||||
image: python:3.7-bullseye
|
||||
volumes:
|
||||
- .:/src
|
||||
working_dir: /src
|
||||
command: sleep infinity
|
BIN
tunmnlu/task_1/Q1/docs/2023-08-28_18-48.png
(Stored with Git LFS)
Normal file
BIN
tunmnlu/task_1/Q1/docs/2023-08-28_18-48.png
(Stored with Git LFS)
Normal file
Binary file not shown.
1
tunmnlu/task_1/Q1/edges.csv
Normal file
1
tunmnlu/task_1/Q1/edges.csv
Normal file
@@ -0,0 +1 @@
|
||||
source,target
|
|
954
tunmnlu/task_1/Q1/edges_ref.csv
Normal file
954
tunmnlu/task_1/Q1/edges_ref.csv
Normal file
@@ -0,0 +1,954 @@
|
||||
source,target
|
||||
2975,6384
|
||||
6384,530
|
||||
6384,1357063
|
||||
6384,40644
|
||||
6384,1779512
|
||||
6384,21127
|
||||
6384,1692944
|
||||
6384,64
|
||||
6384,1776
|
||||
6384,38803
|
||||
6384,20215
|
||||
6384,2130
|
||||
2975,530
|
||||
2975,8349
|
||||
2975,8351
|
||||
2975,8354
|
||||
2975,1107983
|
||||
2975,52057
|
||||
2975,110380
|
||||
2975,18471
|
||||
2975,74611
|
||||
2975,1407498
|
||||
530,529
|
||||
530,532
|
||||
1357063,40644
|
||||
1357063,3894
|
||||
1357063,1892
|
||||
1357063,19498
|
||||
40644,1779512
|
||||
40644,2710
|
||||
40644,4587
|
||||
40644,8691
|
||||
40644,72129
|
||||
40644,189111
|
||||
40644,23964
|
||||
1779512,1357063
|
||||
21127,1692944
|
||||
21127,9827
|
||||
21127,143103
|
||||
21127,21708
|
||||
21127,72983
|
||||
21127,124909
|
||||
21127,4038
|
||||
21127,18992
|
||||
21127,2047
|
||||
21127,4730
|
||||
21127,9464
|
||||
21127,14409
|
||||
64,1776
|
||||
64,1415341
|
||||
64,1267653
|
||||
64,7467
|
||||
64,1519399
|
||||
64,1003
|
||||
64,524
|
||||
64,38803
|
||||
64,3894
|
||||
64,1810
|
||||
64,3895
|
||||
64,958722
|
||||
64,41381
|
||||
64,10980
|
||||
64,10989
|
||||
64,10990
|
||||
64,20215
|
||||
64,2130
|
||||
64,219479
|
||||
64,1101349
|
||||
64,1407495
|
||||
64,3361135
|
||||
64,1812
|
||||
64,2037
|
||||
64,5081
|
||||
64,1892
|
||||
1776,2559324
|
||||
1776,2559325
|
||||
1776,27888
|
||||
1776,2630
|
||||
1776,958722
|
||||
1776,41381
|
||||
1776,38803
|
||||
1776,151007
|
||||
1776,1769
|
||||
1776,19772
|
||||
1776,1
|
||||
1776,7879
|
||||
1776,20215
|
||||
1776,2130
|
||||
1776,1032
|
||||
1776,1006721
|
||||
1776,11483
|
||||
1776,8349
|
||||
1776,8351
|
||||
1776,8354
|
||||
38803,151007
|
||||
38803,5953
|
||||
38803,325
|
||||
38803,3125
|
||||
38803,3084
|
||||
38803,1158
|
||||
38803,3085
|
||||
38803,3087
|
||||
38803,3092
|
||||
20215,2130
|
||||
20215,117669
|
||||
20215,558466
|
||||
20215,61555
|
||||
20215,10017
|
||||
20215,5563
|
||||
20215,26557
|
||||
20215,18688
|
||||
20215,8437
|
||||
20215,589
|
||||
2130,16431
|
||||
2130,2203
|
||||
2130,3026
|
||||
2130,32
|
||||
2130,12132
|
||||
2130,932719
|
||||
2130,2127
|
||||
2130,2128
|
||||
2130,2675
|
||||
8349,8351
|
||||
8349,8354
|
||||
8349,1278399
|
||||
8349,1659326
|
||||
8349,26466
|
||||
8349,18269
|
||||
8349,5606
|
||||
8349,5632
|
||||
8349,1179102
|
||||
8349,11367
|
||||
8349,31028
|
||||
8349,1397846
|
||||
8349,2166741
|
||||
8349,3266
|
||||
8349,36059
|
||||
8349,21010
|
||||
8349,101032
|
||||
8349,98569
|
||||
8349,2080584
|
||||
8349,103835
|
||||
8349,6717
|
||||
8349,928944
|
||||
8349,2022250
|
||||
8349,9979
|
||||
8349,514
|
||||
8349,6193
|
||||
8349,1892
|
||||
8349,2641
|
||||
8349,92029
|
||||
8349,218506
|
||||
8349,2098136
|
||||
8349,2098137
|
||||
8349,2098138
|
||||
8351,8354
|
||||
1107983,52057
|
||||
1107983,110380
|
||||
1107983,181934
|
||||
1107983,496175
|
||||
1107983,1280183
|
||||
1107983,1006651
|
||||
1107983,237876
|
||||
1107983,180659
|
||||
1107983,1165240
|
||||
1107983,2787630
|
||||
1107983,89289
|
||||
1107983,2102583
|
||||
1107983,73988
|
||||
1107983,21111
|
||||
1107983,2803017
|
||||
1107983,2803001
|
||||
1107983,4193575
|
||||
1107983,4193577
|
||||
1107983,4193578
|
||||
1107983,2954
|
||||
1107983,33663
|
||||
1107983,2301996
|
||||
1107983,214317
|
||||
1107983,13716
|
||||
1107983,117180
|
||||
1107983,23626
|
||||
1107983,937663
|
||||
1107983,1931175
|
||||
1107983,12951
|
||||
1107983,2998183
|
||||
1107983,1231277
|
||||
52057,110380
|
||||
52057,60158
|
||||
52057,24810
|
||||
52057,2535
|
||||
52057,225620
|
||||
52057,1683093
|
||||
52057,79538
|
||||
52057,1562353
|
||||
52057,1038
|
||||
52057,4173
|
||||
52057,349
|
||||
110380,4587
|
||||
110380,9780
|
||||
110380,19011
|
||||
110380,146687
|
||||
110380,74266
|
||||
110380,1507609
|
||||
110380,1507612
|
||||
110380,1507613
|
||||
110380,1122373
|
||||
110380,1122374
|
||||
110380,1122375
|
||||
18471,74611
|
||||
18471,1407498
|
||||
18471,1897
|
||||
18471,77896
|
||||
18471,2395
|
||||
18471,1735828
|
||||
18471,53397
|
||||
18471,1224841
|
||||
18471,539
|
||||
18471,111513
|
||||
18471,514
|
||||
18471,6193
|
||||
18471,1892
|
||||
74611,1407498
|
||||
74611,2682390
|
||||
74611,2227
|
||||
74611,4430
|
||||
74611,14837
|
||||
74611,5823
|
||||
74611,3141
|
||||
74611,449538
|
||||
74611,13309
|
||||
74611,1661465
|
||||
1407498,2395
|
||||
1407498,1735828
|
||||
1407498,53397
|
||||
1407498,102786
|
||||
1407498,128550
|
||||
1407498,2320880
|
||||
529,532
|
||||
529,46300
|
||||
529,27889
|
||||
529,1331
|
||||
529,326
|
||||
529,323
|
||||
529,11099
|
||||
532,6384
|
||||
532,2975
|
||||
532,7187
|
||||
532,57371
|
||||
532,3034
|
||||
3894,6968
|
||||
3894,3895
|
||||
3894,1810
|
||||
3894,1892
|
||||
3894,19498
|
||||
3894,11669
|
||||
3894,43120
|
||||
3894,53926
|
||||
3894,34947
|
||||
3894,1262612
|
||||
3894,21200
|
||||
3894,525
|
||||
3894,15556
|
||||
3894,3361135
|
||||
3894,1812
|
||||
3894,131286
|
||||
3894,60634
|
||||
3894,7133
|
||||
3894,15762
|
||||
3894,1160
|
||||
3894,1813
|
||||
1892,2157
|
||||
1892,880
|
||||
1892,1231844
|
||||
1892,1214256
|
||||
1892,19498
|
||||
1892,514
|
||||
1892,6193
|
||||
1892,2037
|
||||
1892,5081
|
||||
1892,31
|
||||
1892,3197
|
||||
1892,12833
|
||||
1892,1810
|
||||
1892,3361135
|
||||
1892,1812
|
||||
1892,10297
|
||||
1892,1813
|
||||
1892,83002
|
||||
1892,21037
|
||||
1892,1800494
|
||||
1892,1775343
|
||||
19498,127712
|
||||
19498,3035
|
||||
19498,527313
|
||||
19498,6193
|
||||
19498,21007
|
||||
19498,234352
|
||||
2710,4587
|
||||
2710,8691
|
||||
2710,869
|
||||
2710,96884
|
||||
2710,1100
|
||||
2710,2713
|
||||
2710,2231
|
||||
2710,1
|
||||
2710,6159
|
||||
2710,2395
|
||||
2710,1735828
|
||||
2710,53397
|
||||
4587,33181
|
||||
4587,63611
|
||||
4587,53574
|
||||
4587,16217
|
||||
4587,9780
|
||||
4587,8691
|
||||
4587,15762
|
||||
4587,1160
|
||||
4587,1813
|
||||
4587,8891
|
||||
4587,44038
|
||||
4587,1121437
|
||||
4587,70243
|
||||
4587,15973
|
||||
4587,16108
|
||||
8691,73475
|
||||
8691,2078350
|
||||
8691,73457
|
||||
8691,543530
|
||||
8691,111946
|
||||
8691,57691
|
||||
8691,343
|
||||
8691,3223
|
||||
8691,74568
|
||||
8691,103
|
||||
8691,16828
|
||||
8691,1897
|
||||
8691,18471
|
||||
8691,77896
|
||||
72129,1851091
|
||||
72129,189111
|
||||
72129,23964
|
||||
72129,3810
|
||||
72129,6431
|
||||
189111,23964
|
||||
23964,1625558
|
||||
23964,112
|
||||
23964,1283
|
||||
9827,143103
|
||||
9827,17606
|
||||
9827,17605
|
||||
9827,75131
|
||||
143103,75131
|
||||
21708,72983
|
||||
21708,124909
|
||||
21708,27442
|
||||
21708,24299
|
||||
21708,5476
|
||||
21708,30721
|
||||
21708,9287
|
||||
21708,70119
|
||||
21708,7502
|
||||
72983,124909
|
||||
72983,86381
|
||||
72983,1012743
|
||||
72983,8767
|
||||
72983,23931
|
||||
72983,121718
|
||||
72983,77003
|
||||
72983,199449
|
||||
72983,819
|
||||
4038,18992
|
||||
4038,2047
|
||||
4038,2222
|
||||
4038,152699
|
||||
4038,4037
|
||||
4038,1269
|
||||
4038,13472
|
||||
4038,13473
|
||||
4038,2607714
|
||||
4038,3896
|
||||
4038,2517086
|
||||
4038,151432
|
||||
4038,3763830
|
||||
4038,133499
|
||||
4038,1724558
|
||||
4038,7904
|
||||
4038,4244
|
||||
4038,13476
|
||||
4038,44301
|
||||
4038,11905
|
||||
4038,38127
|
||||
4038,231318
|
||||
18992,2047
|
||||
18992,2130
|
||||
18992,16431
|
||||
18992,2203
|
||||
2047,1027445
|
||||
2047,1027448
|
||||
2047,155474
|
||||
2047,232449
|
||||
2047,2049
|
||||
2047,11784
|
||||
2047,65398
|
||||
2047,2390
|
||||
2047,58493
|
||||
2047,22860
|
||||
2047,44822
|
||||
2047,1669775
|
||||
2047,5247
|
||||
2047,20904
|
||||
2047,157963
|
||||
2047,74375
|
||||
2047,155890
|
||||
2047,2210813
|
||||
2047,2879828
|
||||
2047,9979
|
||||
2047,9789
|
||||
2047,6449
|
||||
4730,9464
|
||||
4730,14409
|
||||
9464,14409
|
||||
9464,1272970
|
||||
9464,1591305
|
||||
9464,1179187
|
||||
9464,291133
|
||||
9464,61223
|
||||
9464,880
|
||||
9464,73968
|
||||
9464,90633
|
||||
14409,151343
|
||||
14409,11275
|
||||
14409,6199
|
||||
14409,4491
|
||||
14409,14405
|
||||
14409,14406
|
||||
14409,3861945
|
||||
14409,566154
|
||||
14409,1141310
|
||||
1415341,1267653
|
||||
7467,1519399
|
||||
7467,57446
|
||||
7467,215486
|
||||
7467,1161962
|
||||
1003,524
|
||||
1003,39350
|
||||
1003,1722308
|
||||
1003,24501
|
||||
1003,39646
|
||||
524,2179581
|
||||
524,1805442
|
||||
524,3499637
|
||||
524,164004
|
||||
524,26472
|
||||
524,3223
|
||||
524,16828
|
||||
524,103
|
||||
1810,3361135
|
||||
1810,1812
|
||||
1810,3895
|
||||
1810,34947
|
||||
1810,1262612
|
||||
1810,21200
|
||||
3895,1291312
|
||||
3895,2983750
|
||||
3895,6968
|
||||
3895,39998
|
||||
3895,7506
|
||||
3895,9979
|
||||
3895,9789
|
||||
3895,6449
|
||||
3895,290
|
||||
3895,8606
|
||||
3895,1304968
|
||||
3895,10297
|
||||
3895,1813
|
||||
3895,83002
|
||||
3895,834
|
||||
3895,16523
|
||||
3895,19460
|
||||
3895,6952
|
||||
3895,114454
|
||||
3895,10017
|
||||
3895,6193
|
||||
3895,24045
|
||||
3895,3899
|
||||
3895,525
|
||||
3895,15556
|
||||
3895,3361135
|
||||
3895,1812
|
||||
958722,41381
|
||||
41381,20215
|
||||
41381,2130
|
||||
41381,6384
|
||||
10980,10989
|
||||
10980,10990
|
||||
10980,475512
|
||||
10980,56323
|
||||
10980,13636
|
||||
10989,1689289
|
||||
10989,11275
|
||||
10989,10990
|
||||
10990,23659
|
||||
10990,152416
|
||||
10990,83873
|
||||
10990,449538
|
||||
10990,87525
|
||||
10990,7056
|
||||
219479,1101349
|
||||
219479,1407495
|
||||
219479,491896
|
||||
219479,969097
|
||||
219479,3785095
|
||||
1101349,1452124
|
||||
1101349,1364893
|
||||
1101349,1744249
|
||||
1101349,1569717
|
||||
1101349,1407495
|
||||
1101349,31515
|
||||
1101349,1218635
|
||||
1101349,1544086
|
||||
1101349,1997030
|
||||
1101349,89056
|
||||
1101349,1101364
|
||||
1101349,1101343
|
||||
1101349,3358480
|
||||
1101349,3358481
|
||||
1101349,3358482
|
||||
1101349,1101342
|
||||
1101349,1016349
|
||||
1101349,108661
|
||||
1101349,214830
|
||||
1101349,1070445
|
||||
1407495,18471
|
||||
1407495,74611
|
||||
1407495,1407498
|
||||
1407495,974169
|
||||
1407495,1098962
|
||||
1407495,1331457
|
||||
3361135,1812
|
||||
1812,6193
|
||||
1812,103
|
||||
1812,2282
|
||||
1812,2682390
|
||||
1812,2227
|
||||
1812,4430
|
||||
2037,96074
|
||||
2037,4569
|
||||
2037,218984
|
||||
2037,15737
|
||||
2037,1167897
|
||||
2037,5081
|
||||
2037,15488
|
||||
2037,73288
|
||||
2037,1844919
|
||||
2037,658
|
||||
2037,6193
|
||||
2037,24045
|
||||
2037,3899
|
||||
2037,3894
|
||||
2037,1810
|
||||
2037,3895
|
||||
2559324,2559325
|
||||
27888,4784
|
||||
27888,13333
|
||||
27888,2630
|
||||
27888,227
|
||||
27888,40542
|
||||
2630,5048
|
||||
2630,923
|
||||
2630,20718
|
||||
2630,4399
|
||||
2630,3564
|
||||
1769,18517
|
||||
1769,101831
|
||||
1769,205
|
||||
1769,2299
|
||||
1769,19772
|
||||
1769,1
|
||||
1769,7879
|
||||
1769,5953
|
||||
1769,325
|
||||
1769,3125
|
||||
1769,3084
|
||||
1769,1158
|
||||
1769,3085
|
||||
1769,3087
|
||||
1769,3092
|
||||
1,7879
|
||||
1,71538
|
||||
1,3993
|
||||
1,553222
|
||||
1,24343
|
||||
1,1021364
|
||||
1,491
|
||||
1,488
|
||||
1,2231
|
||||
1,6159
|
||||
1,5026
|
||||
1,132305
|
||||
1,18598
|
||||
1,11770
|
||||
1,515
|
||||
1,349
|
||||
1,1032
|
||||
1,1006721
|
||||
1,11483
|
||||
1,4
|
||||
1,3799
|
||||
1,130
|
||||
1,33185
|
||||
1,670
|
||||
1,10930
|
||||
1,2140901
|
||||
1,2
|
||||
1,9979
|
||||
1,9789
|
||||
1,6449
|
||||
7879,15811
|
||||
7879,61416
|
||||
7879,94037
|
||||
7879,7314
|
||||
7879,35219
|
||||
7879,31
|
||||
7879,109255
|
||||
7879,2106
|
||||
7879,146136
|
||||
7879,628
|
||||
7879,608
|
||||
7879,1417
|
||||
7879,1186197
|
||||
7879,110675
|
||||
7879,574290
|
||||
7879,2231
|
||||
7879,6159
|
||||
1032,1130441
|
||||
1032,108650
|
||||
1032,1006721
|
||||
1032,11483
|
||||
1032,380
|
||||
1032,16514
|
||||
1032,1130439
|
||||
1032,2585
|
||||
1032,1044
|
||||
1032,3661
|
||||
1032,5026
|
||||
1032,132305
|
||||
1032,18598
|
||||
1032,3636
|
||||
1032,109410
|
||||
1032,4135
|
||||
1032,1052109
|
||||
1032,1052107
|
||||
1032,1146050
|
||||
1032,11478
|
||||
1032,6193
|
||||
1032,83198
|
||||
1032,101377
|
||||
1032,141
|
||||
1032,8487
|
||||
1032,7046
|
||||
1032,1102449
|
||||
1032,155890
|
||||
1032,2210813
|
||||
1032,2879828
|
||||
1032,190
|
||||
1032,14701
|
||||
1032,6449
|
||||
1032,3264451
|
||||
1032,1034310
|
||||
1032,126750
|
||||
1032,9979
|
||||
1032,9789
|
||||
1032,1038
|
||||
1032,1036
|
||||
1006721,11483
|
||||
1006721,11477
|
||||
1006721,380
|
||||
1006721,4517
|
||||
1006721,1038
|
||||
1006721,1036
|
||||
11483,11477
|
||||
11483,380
|
||||
11483,4517
|
||||
11483,4430
|
||||
11483,1038
|
||||
11483,1036
|
||||
5953,325
|
||||
5953,3125
|
||||
5953,1314108
|
||||
5953,9656
|
||||
5953,61441
|
||||
5953,110068
|
||||
5953,56584
|
||||
5953,2092052
|
||||
5953,2003784
|
||||
5953,1873369
|
||||
5953,6193
|
||||
5953,21007
|
||||
5953,234352
|
||||
325,84534
|
||||
325,9315
|
||||
325,70851
|
||||
325,134
|
||||
325,544016
|
||||
325,62644
|
||||
325,2041
|
||||
325,1740159
|
||||
325,1740160
|
||||
325,1945289
|
||||
325,2191424
|
||||
325,2191425
|
||||
325,1135272
|
||||
325,337
|
||||
325,2689367
|
||||
325,3125
|
||||
325,1549410
|
||||
325,214586
|
||||
325,323
|
||||
325,339
|
||||
325,1776464
|
||||
325,4244
|
||||
325,4238
|
||||
325,37934
|
||||
325,15310
|
||||
325,12207
|
||||
325,154782
|
||||
325,154783
|
||||
325,174875
|
||||
3125,1114225
|
||||
3125,1114226
|
||||
3125,116152
|
||||
3125,116153
|
||||
3125,123448
|
||||
3125,2392722
|
||||
3125,2973752
|
||||
3125,1093165
|
||||
3125,116341
|
||||
3125,128550
|
||||
3125,111946
|
||||
3125,1214377
|
||||
3125,56288
|
||||
3125,1059545
|
||||
3125,37934
|
||||
3125,15310
|
||||
3125,12207
|
||||
3125,32797
|
||||
3125,1193602
|
||||
3125,120615
|
||||
3125,88339
|
||||
3125,116154
|
||||
3125,1795433
|
||||
3125,72208
|
||||
3125,3284
|
||||
3125,18746
|
||||
3125,2240369
|
||||
3125,82280
|
||||
3125,40092
|
||||
3125,21397
|
||||
3125,134
|
||||
3125,3981237
|
||||
3125,104156
|
||||
3125,38406
|
||||
3125,1226426
|
||||
3084,18329
|
||||
3084,4426
|
||||
3084,1158
|
||||
3084,3087
|
||||
3084,3085
|
||||
3084,18269
|
||||
3084,147
|
||||
3084,82702
|
||||
3084,65605
|
||||
3084,47775
|
||||
3084,8349
|
||||
3084,8351
|
||||
3084,8354
|
||||
3084,4483
|
||||
3084,13570
|
||||
3084,3417
|
||||
3084,68402
|
||||
3084,5049
|
||||
3084,68381
|
||||
3084,4053937
|
||||
3084,4053939
|
||||
3084,4053940
|
||||
3084,104156
|
||||
3084,38406
|
||||
3084,1226426
|
||||
1158,1159
|
||||
1158,1160
|
||||
1158,3087
|
||||
1158,3092
|
||||
1158,3085
|
||||
1158,1150
|
||||
1158,1151
|
||||
3085,7447
|
||||
3085,9560
|
||||
3085,3087
|
||||
3085,5682
|
||||
3085,44556
|
||||
3085,20234
|
||||
3085,1487
|
||||
3085,111714
|
||||
3085,165867
|
||||
3085,3092
|
||||
3087,3092
|
||||
3087,1056052
|
||||
3087,500
|
||||
3087,12132
|
||||
3087,2130
|
||||
3087,932719
|
||||
3087,8349
|
||||
3087,8351
|
||||
3087,8354
|
||||
3087,106179
|
||||
3087,10190
|
||||
3087,5250
|
||||
3087,8483
|
||||
3087,8482
|
||||
3087,6349
|
||||
3087,8487
|
||||
3087,8488
|
||||
3087,8489
|
||||
3092,3084
|
||||
117669,558466
|
||||
117669,61555
|
||||
558466,235416
|
||||
558466,1281967
|
||||
558466,61555
|
||||
558466,1604285
|
||||
558466,1105441
|
||||
61555,66744
|
||||
61555,53286
|
||||
61555,8184
|
||||
10017,5563
|
||||
10017,26557
|
||||
10017,1028353
|
||||
10017,1028355
|
||||
10017,6952
|
||||
10017,114454
|
||||
10017,707
|
||||
10017,26485
|
||||
10017,54812
|
||||
10017,4430
|
||||
10017,6449
|
||||
10017,516
|
||||
10017,2116053
|
||||
10017,1119476
|
||||
10017,3947315
|
||||
10017,4786
|
||||
10017,326
|
||||
5563,51816
|
||||
5563,46602
|
||||
5563,26557
|
||||
5563,14101
|
||||
5563,18794
|
||||
5563,85139
|
||||
5563,19429
|
||||
5563,18897
|
||||
5563,51576
|
||||
5563,2103203
|
||||
5563,131168
|
||||
26557,17844
|
||||
26557,6263
|
||||
26557,10254
|
||||
26557,15196
|
||||
26557,46780
|
||||
26557,66884
|
||||
26557,2883
|
||||
26557,3011
|
||||
26557,5147
|
||||
26557,67676
|
||||
26557,116838
|
||||
26557,100787
|
||||
26557,1921578
|
||||
26557,2106
|
||||
26557,239398
|
||||
26557,31070
|
||||
26557,31071
|
||||
26557,2264
|
||||
18688,8437
|
||||
18688,589
|
||||
18688,17604
|
||||
18688,418
|
||||
18688,138986
|
||||
18688,1532769
|
||||
18688,1109331
|
||||
18688,86449
|
||||
8437,64825
|
||||
8437,12646
|
||||
8437,589
|
||||
8437,91332
|
||||
8437,78805
|
||||
8437,7180
|
||||
8437,14882
|
||||
8437,7503
|
||||
8437,14639
|
||||
8437,14670
|
||||
8437,1895
|
||||
8437,22860
|
||||
8437,7172
|
||||
8437,1172565
|
||||
589,1572034
|
||||
589,2555
|
||||
589,7004
|
||||
589,138
|
||||
589,2545
|
||||
589,141
|
||||
589,2144
|
||||
589,2505
|
||||
16431,2203
|
||||
16431,17604
|
||||
16431,1215054
|
||||
3026,32
|
||||
3026,9248
|
||||
3026,7904
|
||||
3026,146307
|
||||
3026,7166
|
||||
3026,39770
|
||||
3026,34721
|
||||
3026,21010
|
||||
3026,6193
|
||||
3026,21007
|
||||
3026,234352
|
||||
3026,16376
|
||||
3026,16377
|
||||
3026,1206
|
||||
3026,4430
|
||||
3026,6449
|
||||
3026,516
|
||||
32,31
|
||||
32,33
|
||||
32,880
|
||||
32,73968
|
||||
32,90633
|
||||
12132,932719
|
||||
12132,32749
|
||||
12132,99
|
||||
12132,6804
|
||||
12132,69302
|
||||
12132,65529
|
||||
12132,101028
|
||||
12132,70303
|
||||
12132,11064
|
||||
12132,73457
|
||||
12132,8691
|
||||
12132,543530
|
||||
932719,1238314
|
||||
932719,204415
|
||||
2127,2128
|
||||
2127,2675
|
||||
2128,2675
|
|
330
tunmnlu/task_1/Q1/helloworld.py
Normal file
330
tunmnlu/task_1/Q1/helloworld.py
Normal file
@@ -0,0 +1,330 @@
|
||||
import http.client
|
||||
import json
|
||||
import csv
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
# cse6242
|
||||
# All instructions, code comments, etc. contained within this notebook are part of the assignment instructions.
|
||||
# Portions of this file will auto-graded in Gradescope using different sets of parameters / data to ensure that values are not
|
||||
# hard-coded.
|
||||
#
|
||||
# Instructions: Implement all methods in this file that have a return
|
||||
# value of 'NotImplemented'. See the documentation within each method for specific details, including
|
||||
# the expected return value
|
||||
#
|
||||
# Helper Functions:
|
||||
# You are permitted to write additional helper functions/methods or use additional instance variables within
|
||||
# the `Graph` class or `TMDbAPIUtils` class so long as the originally included methods work as required.
|
||||
#
|
||||
# Use:
|
||||
# The `Graph` class is used to represent and store the data for the TMDb co-actor network graph. This class must
|
||||
# also provide some basic analytics, i.e., number of nodes, edges, and nodes with the highest degree.
|
||||
#
|
||||
# The `TMDbAPIUtils` class is used to retrieve Actor/Movie data using themoviedb.org API. We have provided a few necessary methods
|
||||
# to test your code w/ the API, e.g.: get_movie_cast(), get_movie_credits_for_person(). You may add additional
|
||||
# methods and instance variables as desired (see Helper Functions).
|
||||
#
|
||||
# The data that you retrieve from the TMDb API is used to build your graph using the Graph class. After you build your graph using the
|
||||
# TMDb API data, use the Graph class write_edges_file & write_nodes_file methods to produce the separate nodes and edges
|
||||
# .csv files for submission to Gradescope.
|
||||
#
|
||||
# While building the co-actor graph, you will be required to write code to expand the graph by iterating
|
||||
# through a portion of the graph nodes and finding similar artists using the TMDb API. We will not grade this code directly
|
||||
# but will grade the resulting graph data in your nodes and edges .csv files.
|
||||
#
|
||||
#############################################################################################################################
|
||||
|
||||
|
||||
class Graph:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, with_nodes_file=None, with_edges_file=None):
|
||||
"""
|
||||
option 1: init as an empty graph and add nodes
|
||||
option 2: init by specifying a path to nodes & edges files
|
||||
"""
|
||||
self.nodes = []
|
||||
self.edges = []
|
||||
if with_nodes_file and with_edges_file:
|
||||
nodes_CSV = csv.reader(open(with_nodes_file))
|
||||
nodes_CSV = list(nodes_CSV)[1:]
|
||||
self.nodes = [(n[0], n[1]) for n in nodes_CSV]
|
||||
|
||||
edges_CSV = csv.reader(open(with_edges_file))
|
||||
edges_CSV = list(edges_CSV)[1:]
|
||||
self.edges = [(e[0], e[1]) for e in edges_CSV]
|
||||
|
||||
|
||||
def add_node(self, id: str, name: str) -> None:
|
||||
"""
|
||||
add a tuple (id, name) representing a node to self.nodes if it does not already exist
|
||||
The graph should not contain any duplicate nodes
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def add_edge(self, source: str, target: str) -> None:
|
||||
"""
|
||||
Add an edge between two nodes if it does not already exist.
|
||||
An edge is represented by a tuple containing two strings: e.g.: ('source', 'target').
|
||||
Where 'source' is the id of the source node and 'target' is the id of the target node
|
||||
e.g., for two nodes with ids 'a' and 'b' respectively, add the tuple ('a', 'b') to self.edges
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def total_nodes(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of nodes in the graph
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def total_edges(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of edges in the graph
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def max_degree_nodes(self) -> dict:
|
||||
"""
|
||||
Return the node(s) with the highest degree
|
||||
Return multiple nodes in the event of a tie
|
||||
Format is a dict where the key is the node_id and the value is an integer for the node degree
|
||||
e.g. {'a': 8}
|
||||
or {'a': 22, 'b': 22}
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def print_nodes(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.nodes)
|
||||
|
||||
|
||||
def print_edges(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.edges)
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_edges_file(self, path="edges.csv")->None:
|
||||
"""
|
||||
write all edges out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
edges_path = path
|
||||
edges_file = open(edges_path, 'w', encoding='utf-8')
|
||||
|
||||
edges_file.write("source" + "," + "target" + "\n")
|
||||
|
||||
for e in self.edges:
|
||||
edges_file.write(e[0] + "," + e[1] + "\n")
|
||||
|
||||
edges_file.close()
|
||||
print("finished writing edges to csv")
|
||||
|
||||
|
||||
# Do not modify
|
||||
def write_nodes_file(self, path="nodes.csv")->None:
|
||||
"""
|
||||
write all nodes out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
nodes_path = path
|
||||
nodes_file = open(nodes_path, 'w', encoding='utf-8')
|
||||
|
||||
nodes_file.write("id,name" + "\n")
|
||||
for n in self.nodes:
|
||||
nodes_file.write(n[0] + "," + n[1] + "\n")
|
||||
nodes_file.close()
|
||||
print("finished writing nodes to csv")
|
||||
|
||||
|
||||
|
||||
class TMDBAPIUtils:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, api_key:str):
|
||||
self.api_key=api_key
|
||||
|
||||
|
||||
def get_movie_cast(self, movie_id:str, limit:int=None, exclude_ids:list=None) -> list:
|
||||
"""
|
||||
Get the movie cast for a given movie id, with optional parameters to exclude an cast member
|
||||
from being returned and/or to limit the number of returned cast members
|
||||
documentation url: https://developers.themoviedb.org/3/movies/get-movie-credits
|
||||
|
||||
:param string movie_id: a movie_id
|
||||
:param list exclude_ids: a list of ints containing ids (not cast_ids) of cast members that should be excluded from the returned result
|
||||
e.g., if exclude_ids are [353, 455] then exclude these from any result.
|
||||
:param integer limit: maximum number of returned cast members by their 'order' attribute
|
||||
e.g., limit=5 will attempt to return the 5 cast members having 'order' attribute values between 0-4
|
||||
If after excluding, there are fewer cast members than the specified limit, then return the remaining members (excluding the ones whose order values are outside the limit range).
|
||||
If cast members with 'order' attribute in the specified limit range have been excluded, do not include more cast members to reach the limit.
|
||||
If after excluding, the limit is not specified, then return all remaining cast members."
|
||||
e.g., if limit=5 and the actor whose id corresponds to cast member with order=1 is to be excluded,
|
||||
return cast members with order values [0, 2, 3, 4], not [0, 2, 3, 4, 5]
|
||||
:rtype: list
|
||||
return a list of dicts, one dict per cast member with the following structure:
|
||||
[{'id': '97909' # the id of the cast member
|
||||
'character': 'John Doe' # the name of the character played
|
||||
'credit_id': '52fe4249c3a36847f8012927' # id of the credit, ...}, ... ]
|
||||
Note that this is an example of the structure of the list and some of the fields returned by the API.
|
||||
The result of the API call will include many more fields for each cast member.
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
def get_movie_credits_for_person(self, person_id:str, vote_avg_threshold:float=None)->list:
|
||||
"""
|
||||
Using the TMDb API, get the movie credits for a person serving in a cast role
|
||||
documentation url: https://developers.themoviedb.org/3/people/get-person-movie-credits
|
||||
|
||||
:param string person_id: the id of a person
|
||||
:param vote_avg_threshold: optional parameter to return the movie credit if it is >=
|
||||
the specified threshold.
|
||||
e.g., if the vote_avg_threshold is 5.0, then only return credits with a vote_avg >= 5.0
|
||||
:rtype: list
|
||||
return a list of dicts, with each dict having 'id', 'title', and 'vote_avg' keys,
|
||||
one dict per movie credit with the following structure:
|
||||
[{'id': '97909' # the id of the movie
|
||||
'title': 'Long, Stock and Two Smoking Barrels' # the title (not original title) of the credit
|
||||
'vote_avg': 5.0 # the float value of the vote average value for the credit}, ... ]
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
#
|
||||
# BUILDING YOUR GRAPH
|
||||
#
|
||||
# Working with the API: See use of http.request: https://docs.python.org/3/library/http.client.html#examples
|
||||
#
|
||||
# Using TMDb's API, build a co-actor network for the actor's/actress' highest rated movies
|
||||
# In this graph, each node represents an actor
|
||||
# An edge between any two nodes indicates that the two actors/actresses acted in a movie together
|
||||
# i.e., they share a movie credit.
|
||||
# e.g., An edge between Samuel L. Jackson and Robert Downey Jr. indicates that they have acted in one
|
||||
# or more movies together.
|
||||
#
|
||||
# For this assignment, we are interested in a co-actor network of highly rated movies; specifically,
|
||||
# we only want the top 3 co-actors in each movie credit of an actor having a vote average >= 8.0.
|
||||
# Build your co-actor graph on the actor 'Laurence Fishburne' w/ person_id 2975.
|
||||
#
|
||||
# You will need to add extra functions or code to accomplish this. We will not directly call or explicitly grade your
|
||||
# algorithm. We will instead measure the correctness of your output by evaluating the data in your nodes.csv and edges.csv files.
|
||||
#
|
||||
# GRAPH SIZE
|
||||
# With each iteration of your graph build, the number of nodes and edges grows approximately at an exponential rate.
|
||||
# Our testing indicates growth approximately equal to e^2x.
|
||||
# Since the TMDB API is a live database, the number of nodes / edges in the final graph will vary slightly depending on when
|
||||
# you execute your graph building code. We take this into account by rebuilding the solution graph every few days and
|
||||
# updating the auto-grader. We establish a bound for lowest & highest encountered numbers of nodes and edges with a
|
||||
# margin of +/- 100 for nodes and +/- 150 for edges. e.g., The allowable range of nodes is set to:
|
||||
#
|
||||
# Min allowable nodes = min encountered nodes - 100
|
||||
# Max allowable nodes = max allowable nodes + 100
|
||||
#
|
||||
# e.g., if the minimum encountered nodes = 507 and the max encountered nodes = 526, then the min/max range is 407-626
|
||||
# The same method is used to calculate the edges with the exception of using the aforementioned edge margin.
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
# BEGIN BUILD CO-ACTOR NETWORK
|
||||
#
|
||||
# INITIALIZE GRAPH
|
||||
# Initialize a Graph object with a single node representing Laurence Fishburne
|
||||
#
|
||||
# BEGIN BUILD BASE GRAPH:
|
||||
# Find all of Laurence Fishburne's movie credits that have a vote average >= 8.0
|
||||
# FOR each movie credit:
|
||||
# | get the movie cast members having an 'order' value between 0-2 (these are the co-actors)
|
||||
# |
|
||||
# | FOR each movie cast member:
|
||||
# | | using graph.add_node(), add the movie cast member as a node (keep track of all new nodes added to the graph)
|
||||
# | | using graph.add_edge(), add an edge between the Laurence Fishburne (actor) node
|
||||
# | | and each new node (co-actor/co-actress)
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END BUILD BASE GRAPH
|
||||
#
|
||||
#
|
||||
# BEGIN LOOP - DO 2 TIMES:
|
||||
# IF first iteration of loop:
|
||||
# | nodes = The nodes added in the BUILD BASE GRAPH (this excludes the original node of Laurence Fishburne!)
|
||||
# ELSE
|
||||
# | nodes = The nodes added in the previous iteration:
|
||||
# ENDIF
|
||||
#
|
||||
# FOR each node in nodes:
|
||||
# | get the movie credits for the actor that have a vote average >= 8.0
|
||||
# |
|
||||
# | FOR each movie credit:
|
||||
# | | try to get the 3 movie cast members having an 'order' value between 0-2
|
||||
# | |
|
||||
# | | FOR each movie cast member:
|
||||
# | | | IF the node doesn't already exist:
|
||||
# | | | | add the node to the graph (track all new nodes added to the graph)
|
||||
# | | | ENDIF
|
||||
# | | |
|
||||
# | | | IF the edge does not exist:
|
||||
# | | | | add an edge between the node (actor) and the new node (co-actor/co-actress)
|
||||
# | | | ENDIF
|
||||
# | | END FOR
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END LOOP
|
||||
#
|
||||
# Your graph should not have any duplicate edges or nodes
|
||||
# Write out your finished graph as a nodes file and an edges file using:
|
||||
# graph.write_edges_file()
|
||||
# graph.write_nodes_file()
|
||||
#
|
||||
# END BUILD CO-ACTOR NETWORK
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Exception handling and best practices
|
||||
# - You should use the param 'language=en-US' in all API calls to avoid encoding issues when writing data to file.
|
||||
# - If the actor name has a comma char ',' it should be removed to prevent extra columns from being inserted into the .csv file
|
||||
# - Some movie_credits do not return cast data. Handle this situation by skipping these instances.
|
||||
# - While The TMDb API does not have a rate-limiting scheme in place, consider that making hundreds / thousands of calls
|
||||
# can occasionally result in timeout errors. If you continue to experience 'ConnectionRefusedError : [Errno 61] Connection refused',
|
||||
# - wait a while and then try again. It may be necessary to insert periodic sleeps when you are building your graph.
|
||||
|
||||
|
||||
def return_name()->str:
|
||||
"""
|
||||
Return a string containing your GT Username
|
||||
e.g., tlou31
|
||||
Do not return your 9 digit GTId
|
||||
"""
|
||||
return NotImplemented
|
||||
|
||||
|
||||
# You should modify __main__ as you see fit to build/test your graph using the TMDBAPIUtils & Graph classes.
|
||||
# Some boilerplate/sample code is provided for demonstration. We will not call __main__ during grading.
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
graph = Graph()
|
||||
graph.add_node(id='2975', name='Laurence Fishburne')
|
||||
tmdb_api_utils = TMDBAPIUtils(api_key='<your API key>')
|
||||
|
||||
# call functions or place code here to build graph (graph building code not graded)
|
||||
# Suggestion: code should contain steps outlined above in BUILD CO-ACTOR NETWORK
|
||||
|
||||
graph.write_edges_file()
|
||||
graph.write_nodes_file()
|
||||
|
||||
# If you have already built & written out your graph, you could read in your nodes & edges files
|
||||
# to perform testing on your graph.
|
||||
# graph = Graph(with_edges_file="edges.csv", with_nodes_file="nodes.csv")
|
16
tunmnlu/task_1/Q1/meta.md
Normal file
16
tunmnlu/task_1/Q1/meta.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
tags: [csv, excel, docker, python]
|
||||
---
|
||||
|
||||
# task1
|
||||
|
||||
ttps://share.louislabs.com/g/u-iOAl1Q6J_
|
||||
|
||||
你好,
|
||||
大致上 Q1 會係咁,
|
||||
份 source 我收埋尾數會交比你。
|
||||
我諗你地應該會有一個叫 GT username 嘅野
|
||||
你可以比我,等我幫手改
|
||||
又或者份 source 到手你自己改都得
|
||||
|
||||
: )
|
1
tunmnlu/task_1/Q1/nodes.csv
Normal file
1
tunmnlu/task_1/Q1/nodes.csv
Normal file
@@ -0,0 +1 @@
|
||||
id,name
|
|
685
tunmnlu/task_1/Q1/nodes_ref.csv
Normal file
685
tunmnlu/task_1/Q1/nodes_ref.csv
Normal file
@@ -0,0 +1,685 @@
|
||||
id,name
|
||||
2975,Laurence Fishburne
|
||||
6384,Keanu Reeves
|
||||
530,Carrie-Anne Moss
|
||||
1357063,Darrin Prescott
|
||||
40644,Chad Stahelski
|
||||
1779512,Jackson Spidell
|
||||
21127,Bobby Cannavale
|
||||
1692944,Heidi Schreck
|
||||
64,Gary Oldman
|
||||
1776,Francis Ford Coppola
|
||||
38803,Roman Coppola
|
||||
20215,Billy Campbell
|
||||
2130,Cary Elwes
|
||||
8349,Martin Sheen
|
||||
8351,Frederic Forrest
|
||||
8354,Albert Hall
|
||||
1107983,Martin Luther King Jr.
|
||||
52057,Obba Babatundé
|
||||
110380,Colin Powell
|
||||
18471,Anthony Anderson
|
||||
74611,Tracee Ellis Ross
|
||||
1407498,Marsai Martin
|
||||
529,Guy Pearce
|
||||
532,Joe Pantoliano
|
||||
3894,Christian Bale
|
||||
1892,Matt Damon
|
||||
19498,Jon Bernthal
|
||||
2710,James Cameron
|
||||
4587,Halle Berry
|
||||
8691,Zoe Saldaña
|
||||
72129,Jennifer Lawrence
|
||||
189111,Suzanne Collins
|
||||
23964,Gary Ross
|
||||
9827,Rose Byrne
|
||||
143103,Krew Boylan
|
||||
21708,Tomas Milian
|
||||
72983,Manny Pérez
|
||||
124909,Danny Hoch
|
||||
4038,Susan Sarandon
|
||||
18992,Aidan Quinn
|
||||
2047,Danny Glover
|
||||
4730,Emmy Rossum
|
||||
9464,Harry Lennix
|
||||
14409,David Schwimmer
|
||||
1415341,Kazuhiro Tsuji
|
||||
1267653,Chet Zar
|
||||
7467,David Fincher
|
||||
1519399,Erik Messerschmidt
|
||||
1003,Jean Reno
|
||||
524,Natalie Portman
|
||||
1810,Heath Ledger
|
||||
3895,Michael Caine
|
||||
958722,Eiko Ishioka
|
||||
41381,Sadie Frost
|
||||
10980,Daniel Radcliffe
|
||||
10989,Rupert Grint
|
||||
10990,Emma Watson
|
||||
219479,Criss Angel
|
||||
1101349,Steve Aoki
|
||||
1407495,Miles Brown
|
||||
3361135,Peter Kent
|
||||
1812,Michelle Williams
|
||||
2037,Cillian Murphy
|
||||
5081,Emily Blunt
|
||||
2559324,Beth Lane
|
||||
2559325,Lea Madda
|
||||
27888,Raúl Juliá
|
||||
2630,Nastassja Kinski
|
||||
151007,Peter Ramsey
|
||||
1769,Sofia Coppola
|
||||
19772,Paul Rassam
|
||||
1,George Lucas
|
||||
7879,John Lasseter
|
||||
1032,Martin Scorsese
|
||||
1006721,Charles Scorsese
|
||||
11483,Catherine Scorsese
|
||||
5953,Spike Jonze
|
||||
325,Eminem
|
||||
3125,Madonna
|
||||
3084,Marlon Brando
|
||||
1158,Al Pacino
|
||||
3085,James Caan
|
||||
3087,Robert Duvall
|
||||
3092,Diane Keaton
|
||||
117669,Portia Doubleday
|
||||
558466,Alex Russell
|
||||
61555,Haley Ramm
|
||||
10017,Charlton Heston
|
||||
5563,James Coburn
|
||||
26557,Ferdy Mayne
|
||||
18688,Harry Connick Jr.
|
||||
8437,Teri Garr
|
||||
589,Daryl Hannah
|
||||
16431,Sam Elliott
|
||||
2203,Neal McDonough
|
||||
3026,Rob Reiner
|
||||
32,Robin Wright
|
||||
12132,Michael Rooker
|
||||
932719,Jeff Gordon
|
||||
2127,James Wan
|
||||
2128,Leigh Whannell
|
||||
2675,Darren Lynn Bousman
|
||||
1278399,Joseph Steven
|
||||
1659326,Teresa Modnick
|
||||
26466,Caroline Kava
|
||||
18269,Brendan Fraser
|
||||
5606,Sissy Spacek
|
||||
5632,Jack Fisk
|
||||
1179102,Kathleen Kennedy
|
||||
11367,Bradley Whitford
|
||||
31028,Richard Schiff
|
||||
1397846,Craig Barron
|
||||
2166741,Robert A. Baum Jr.
|
||||
3266,Joe Mantegna
|
||||
36059,Joanna Pacula
|
||||
21010,Alexandra Hay
|
||||
101032,Rod McCary
|
||||
98569,Vincent Van Patten
|
||||
2080584,Ben Jorgensen
|
||||
103835,Jeff Monahan
|
||||
6717,James Marshall
|
||||
928944,Coleman Barks
|
||||
2022250,Robert Bly
|
||||
9979,Peter Coyote
|
||||
514,Jack Nicholson
|
||||
6193,Leonardo DiCaprio
|
||||
2641,Martin Landau
|
||||
92029,Gabriel Bologna
|
||||
218506,Gretchen Becker
|
||||
2098136,Brian Becker
|
||||
2098137,Richard Becker
|
||||
2098138,Blase Bonpane
|
||||
181934,Al Sharpton
|
||||
496175,Carmelo Anthony
|
||||
1280183,Coretta Scott King
|
||||
1006651,John Lewis
|
||||
237876,Sarah-Jane Sauvegrain
|
||||
180659,Rosa Parks
|
||||
1165240,Jason Alan Carvell
|
||||
2787630,Valentin Zorin
|
||||
89289,Jesse Jackson
|
||||
2102583,Andrew Cohen
|
||||
73988,Lyndon B. Johnson
|
||||
21111,John F. Kennedy
|
||||
2803017,Arthur John Birch
|
||||
2803001,Haroldson Lafayette Hunt
|
||||
4193575,Maxime Demigné
|
||||
4193577,Gabin Clerc
|
||||
4193578,Tom Chabeau
|
||||
2954,Jeffrey Wright
|
||||
33663,Donald Trump
|
||||
2301996,Mike Pence
|
||||
214317,Ben Bradlee
|
||||
13716,Carl Bernstein
|
||||
117180,Tom Brokaw
|
||||
23626,Liev Schreiber
|
||||
937663,Neil Amdur
|
||||
1931175,Bob Beamon
|
||||
12951,O.J. Simpson
|
||||
2998183,Nicole Brown Simpson
|
||||
1231277,Marcia Clark
|
||||
60158,Shirley Jones
|
||||
24810,Pat Boone
|
||||
2535,Vivica A. Fox
|
||||
225620,Rudolph Moise
|
||||
1683093,Terayle Hill
|
||||
79538,Khalil Kain
|
||||
1562353,Erica Mena
|
||||
1038,Jodie Foster
|
||||
4173,Anthony Hopkins
|
||||
349,Scott Glenn
|
||||
9780,Angela Bassett
|
||||
19011,George W. Bush
|
||||
146687,Tony Blair
|
||||
74266,Dick Cheney
|
||||
1507609,Bob Coen
|
||||
1507612,Francis E. Boyle
|
||||
1507613,Jean Patterson
|
||||
1122373,Marion Barry Jr.
|
||||
1122374,Chuck Brown
|
||||
1122375,Lewis Franklin
|
||||
1897,Bernie Mac
|
||||
77896,Bill Bellamy
|
||||
2395,Whoopi Goldberg
|
||||
1735828,Halle Bailey
|
||||
53397,Christina Aguilera
|
||||
1224841,Mo Willems
|
||||
539,Thomas Lennon
|
||||
111513,Yvette Nicole Brown
|
||||
2682390,Gerd Ludwig
|
||||
2227,Nicole Kidman
|
||||
4430,Sharon Stone
|
||||
14837,Carol Burnett
|
||||
5823,Julie Andrews
|
||||
3141,Marisa Tomei
|
||||
449538,Adele
|
||||
13309,Oprah Winfrey
|
||||
1661465,Lizzo
|
||||
102786,Barack Obama
|
||||
128550,Desmond Tutu
|
||||
2320880,Sundar Pichai
|
||||
46300,Alexander Nathan Etel
|
||||
27889,Stephan Elliott
|
||||
1331,Hugo Weaving
|
||||
326,Kim Basinger
|
||||
323,Curtis Hanson
|
||||
11099,Dante Spinotti
|
||||
7187,Richard Donner
|
||||
57371,Jeff Cohen
|
||||
3034,Corey Feldman
|
||||
6968,Hugh Jackman
|
||||
11669,Jimmy Fallon
|
||||
43120,Andy Dick
|
||||
53926,Jon Heder
|
||||
34947,Kevin Conroy
|
||||
1262612,Neal Adams
|
||||
21200,Will Arnett
|
||||
525,Christopher Nolan
|
||||
15556,Rebecca Hall
|
||||
131286,Mark David
|
||||
60634,Marty Belafsky
|
||||
7133,Max Casella
|
||||
15762,Tara Strong
|
||||
1160,Michelle Pfeiffer
|
||||
1813,Anne Hathaway
|
||||
2157,Robin Williams
|
||||
880,Ben Affleck
|
||||
1231844,Manny Ramírez
|
||||
1214256,Curt Schilling
|
||||
31,Tom Hanks
|
||||
3197,Tom Sizemore
|
||||
12833,Edward Burns
|
||||
10297,Matthew McConaughey
|
||||
83002,Jessica Chastain
|
||||
21037,Prince
|
||||
1800494,Cora Coleman-Dunham
|
||||
1775343,Josh Dunham
|
||||
127712,Matt Ryan
|
||||
3035,Jerry O'Connell
|
||||
527313,Taissa Farmiga
|
||||
21007,Jonah Hill
|
||||
234352,Margot Robbie
|
||||
869,Gale Anne Hurd
|
||||
96884,Al Giddings
|
||||
1100,Arnold Schwarzenegger
|
||||
2713,Linda Hamilton
|
||||
2231,Samuel L. Jackson
|
||||
6159,Ron Howard
|
||||
33181,Jimmy Smits
|
||||
63611,Nickolas Grace
|
||||
53574,Eric Thal
|
||||
16217,Lynn Whitfield
|
||||
8891,John Travolta
|
||||
44038,Nancy Allen
|
||||
1121437,Leslie Felperin
|
||||
70243,Eartha Kitt
|
||||
15973,Julie Newmar
|
||||
16108,Lee Meriwether
|
||||
73475,Adriano Giannini
|
||||
2078350,Tommaso Basili
|
||||
73457,Chris Pratt
|
||||
543530,Dave Bautista
|
||||
111946,Britney Spears
|
||||
57691,Tamra Davis
|
||||
343,Taryn Manning
|
||||
3223,Robert Downey Jr.
|
||||
74568,Chris Hemsworth
|
||||
103,Mark Ruffalo
|
||||
16828,Chris Evans
|
||||
1851091,Josh Silver
|
||||
3810,Javier Bardem
|
||||
6431,Darren Aronofsky
|
||||
1625558,Awkwafina
|
||||
112,Cate Blanchett
|
||||
1283,Helena Bonham Carter
|
||||
17606,Imogen Poots
|
||||
17605,Idris Elba
|
||||
75131,Nash Edgerton
|
||||
27442,Renato Salvatori
|
||||
24299,Jean-Claude Brialy
|
||||
5476,Nino Castelnuovo
|
||||
30721,Madeleine Robinson
|
||||
9287,Robert Blake
|
||||
70119,Catherine Spaak
|
||||
7502,Ernest Borgnine
|
||||
86381,Algenis Perez Soto
|
||||
1012743,Dalisa Alegría
|
||||
8767,Jim Caviezel
|
||||
23931,Mira Sorvino
|
||||
121718,Bill Camp
|
||||
77003,Gavin O'Connor
|
||||
199449,Greg O'Connor
|
||||
819,Edward Norton
|
||||
2222,Beau Bridges
|
||||
152699,James Noble
|
||||
4037,Ron Shelton
|
||||
1269,Kevin Costner
|
||||
13472,Tim Curry
|
||||
13473,Barry Bostwick
|
||||
2607714,Alan Cooke
|
||||
3896,Liam Neeson
|
||||
2517086,Will Hochman
|
||||
151432,Boris McGiver
|
||||
3763830,Jim Forbes
|
||||
133499,Christopher Biggins
|
||||
1724558,Justin Arnold
|
||||
7904,Billy Crystal
|
||||
4244,Lauryn Hill
|
||||
13476,Nell Campbell
|
||||
44301,Cliff DeYoung
|
||||
11905,Sven Nykvist
|
||||
38127,Erland Josephson
|
||||
231318,Melinda Kinnaman
|
||||
1027445,Hedviges Mamudo
|
||||
1027448,Melanie de Vales Rafael
|
||||
155474,Keb' Mo'
|
||||
232449,Yolonda Williams
|
||||
2049,Rubén Blades
|
||||
11784,Tom Atkins
|
||||
65398,Denise Nicholas
|
||||
2390,LeVar Burton
|
||||
58493,Tim Grimm
|
||||
22860,Chuck Berry
|
||||
44822,Starletta DuPois
|
||||
1669775,Lou Ferguson
|
||||
5247,John Fiedler
|
||||
20904,James Hong
|
||||
157963,Loren Avedon
|
||||
74375,Cynthia Rothrock
|
||||
155890,Julie Garfield
|
||||
2210813,Ellen Adler
|
||||
2879828,Joseph Bernard
|
||||
9789,Robert Altman
|
||||
6449,Warren Beatty
|
||||
1272970,Christina Wren
|
||||
1591305,MorningStar Angeline
|
||||
1179187,T'Shaun Barrett
|
||||
291133,Tai Bennett
|
||||
61223,Sharon Brathwaite-Sanders
|
||||
73968,Henry Cavill
|
||||
90633,Gal Gadot
|
||||
151343,David Baddiel
|
||||
11275,Stephen Fry
|
||||
6199,Miriam Margolyes
|
||||
4491,Jennifer Aniston
|
||||
14405,Courteney Cox
|
||||
14406,Lisa Kudrow
|
||||
3861945,Rob Helms
|
||||
566154,Bruce Daniels
|
||||
1141310,Joe Dietl
|
||||
57446,Mark Romanek
|
||||
215486,Fiona Apple
|
||||
1161962,Brian Bell
|
||||
39350,Anémone
|
||||
1722308,Jan Vancoillie
|
||||
24501,Pierre Richard
|
||||
39646,Mireille Darc
|
||||
2179581,Tarek Aylouch
|
||||
1805442,Michael Markiewicz
|
||||
3499637,Nick Garrison
|
||||
164004,Ken Cheeseman
|
||||
26472,Steve Guttenberg
|
||||
1291312,Jürgen Thormann
|
||||
2983750,Peter Garloff
|
||||
39998,Tim McIntire
|
||||
7506,Irwin Allen
|
||||
290,Christopher Plummer
|
||||
8606,Robert Shaw
|
||||
1304968,June Tobin
|
||||
834,Otto Preminger
|
||||
16523,Burgess Meredith
|
||||
19460,Saul Bass
|
||||
6952,Charlie Sheen
|
||||
114454,BJ Davis
|
||||
24045,Joseph Gordon-Levitt
|
||||
3899,Ken Watanabe
|
||||
475512,Ellie Kemper
|
||||
56323,Tina Fey
|
||||
13636,Jane Krakowski
|
||||
1689289,Justine Lupe
|
||||
23659,Will Ferrell
|
||||
152416,Murray Bartlett
|
||||
83873,June Diane Raphael
|
||||
87525,Alan Carr
|
||||
7056,Emma Thompson
|
||||
491896,Brie Garcia
|
||||
969097,Nikki Garcia
|
||||
3785095,Kathy Colace
|
||||
1452124,Jason Derulo
|
||||
1364893,Iggy Azalea
|
||||
1744249,Kygo
|
||||
1569717,Martin Garrix
|
||||
31515,Mark Cuban
|
||||
1218635,Gary Vaynerchuk
|
||||
1544086,Min Yoon-gi
|
||||
1997030,Halsey
|
||||
89056,David Guetta
|
||||
1101364,Josh Wink
|
||||
1101343,Carl Cox
|
||||
3358480,Alan Walker
|
||||
3358481,Margrethe Alida
|
||||
3358482,Au/Ra
|
||||
1101342,Sven Väth
|
||||
1016349,Norman Cook
|
||||
108661,Chester Bennington
|
||||
214830,Mike Shinoda
|
||||
1070445,Brad Delson
|
||||
974169,Jenna Ortega
|
||||
1098962,Dove Cameron
|
||||
1331457,Sofia Carson
|
||||
2282,Ben Kingsley
|
||||
96074,Leslie Feist
|
||||
4569,David Fox
|
||||
218984,Johnny Ward
|
||||
15737,Helen McCrory
|
||||
1167897,Natasha O'Keeffe
|
||||
15488,Ken Loach
|
||||
73288,Michael McElhatton
|
||||
1844919,Sam McGovern
|
||||
658,Alfred Molina
|
||||
4784,Laura Dern
|
||||
13333,Vanessa Redgrave
|
||||
227,William Hurt
|
||||
40542,Héctor Babenco
|
||||
5048,Harry Dean Stanton
|
||||
923,Dean Stockwell
|
||||
20718,Claude Berri
|
||||
4399,Timothy Burrill
|
||||
3564,Hervé de Luze
|
||||
18517,Kim Gordon
|
||||
101831,Thurston Moore
|
||||
205,Kirsten Dunst
|
||||
2299,Josh Hartnett
|
||||
71538,Dave Filoni
|
||||
3993,Dennis Muren
|
||||
553222,Bill Moyers
|
||||
24343,Peter Mayhew
|
||||
1021364,Joseph Campbell
|
||||
491,John Williams
|
||||
488,Steven Spielberg
|
||||
5026,Akira Kurosawa
|
||||
132305,Nobuhiko Obayashi
|
||||
18598,Ishirō Honda
|
||||
11770,John Carpenter
|
||||
515,Glenn Close
|
||||
4,Carrie Fisher
|
||||
3799,Billy Dee Williams
|
||||
130,Kenny Baker
|
||||
33185,Jeremy Bulloch
|
||||
670,Ben Burtt
|
||||
10930,Irvin Kershner
|
||||
2140901,Gary Kurtz
|
||||
2,Mark Hamill
|
||||
15811,John Musker
|
||||
61416,Peter Del Vecho
|
||||
94037,Bruno Bozzetto
|
||||
7314,Nick Park
|
||||
35219,Corey Burton
|
||||
109255,Leonard Maltin
|
||||
2106,Walt Disney
|
||||
146136,Bernice Hansen
|
||||
628,Isao Takahata
|
||||
608,Hayao Miyazaki
|
||||
1417,Toshio Suzuki
|
||||
1186197,Steve Alpert
|
||||
110675,Jerry Beck
|
||||
574290,Dave Bossert
|
||||
1130441,Robert Sklar
|
||||
108650,Alain Silver
|
||||
380,Robert De Niro
|
||||
16514,Robert Chartoff
|
||||
1130439,Drew Casper
|
||||
2585,Eric Clapton
|
||||
1044,Michael Chapman
|
||||
3661,Thelma Schoonmaker
|
||||
3636,Paul Newman
|
||||
109410,Joanne Woodward
|
||||
4135,Robert Redford
|
||||
1052109,Harry Styles
|
||||
1052107,Niall Horan
|
||||
1146050,Zayn Malik
|
||||
11478,Lorraine Bracco
|
||||
83198,Allan Arkush
|
||||
101377,Paul Bartel
|
||||
141,David Carradine
|
||||
8487,Gregory Peck
|
||||
7046,Cecilia Peck
|
||||
1102449,Veronique Peck
|
||||
190,Clint Eastwood
|
||||
14701,Carroll Baker
|
||||
3264451,Ann Adachi-Tasch
|
||||
1034310,Margaret Bodde
|
||||
126750,Serge Bromberg
|
||||
1036,Cybill Shepherd
|
||||
11477,Ray Liotta
|
||||
4517,Joe Pesci
|
||||
1314108,FatLip
|
||||
9656,Johnny Knoxville
|
||||
61441,Rick Kosick
|
||||
110068,Ryan Dunn
|
||||
56584,Bam Margera
|
||||
2092052,Ryder McLaughlin
|
||||
2003784,Na-kel Smith
|
||||
1873369,Aramis Hudson
|
||||
84534,Dido
|
||||
9315,Marilyn Manson
|
||||
70851,Jack Black
|
||||
134,Jamie Foxx
|
||||
544016,D12
|
||||
62644,50 Cent
|
||||
2041,Dr. Dre
|
||||
1740159,Marky Bass
|
||||
1740160,Jeff Bass
|
||||
1945289,Denaun Porter
|
||||
2191424,Courtney Butcher
|
||||
2191425,Pj Jacokes
|
||||
1135272,Skylar Grey
|
||||
337,Proof
|
||||
2689367,Swifty McVay
|
||||
1549410,Dead Prez
|
||||
214586,Melle Mel
|
||||
339,Brian Grazer
|
||||
1776464,Stretch Armstrong
|
||||
4238,Common
|
||||
37934,André 3000
|
||||
15310,Anthony Kiedis
|
||||
12207,Kylie Minogue
|
||||
154782,Pat Benatar
|
||||
154783,Neil Giraldo
|
||||
174875,Carly Simon
|
||||
1114225,Kevin Antunes
|
||||
1114226,Monte Pittman
|
||||
116152,Donna DeLory
|
||||
116153,Niki Haris
|
||||
123448,Stuart Price
|
||||
2392722,Steve Sidelnyk
|
||||
2973752,Erika Belle
|
||||
1093165,Christopher Ciccone
|
||||
116341,Bill Clinton
|
||||
1214377,Felicia Culotta
|
||||
56288,Alysson Paradis
|
||||
1059545,Sidney Duteil
|
||||
32797,Arianne Phillips
|
||||
1193602,Gia Coppola
|
||||
120615,Tom Ford
|
||||
88339,Kevin Stea
|
||||
116154,Luis Camacho
|
||||
1795433,Oliver Crumes
|
||||
72208,Alicia Keys
|
||||
3284,Bruce Springsteen
|
||||
18746,Stevie Wonder
|
||||
2240369,Bert Stern
|
||||
82280,Louis Armstrong
|
||||
40092,Twiggy
|
||||
21397,Dennis Rodman
|
||||
3981237,Shirley Rodman
|
||||
104156,Ann-Marie MacDonald
|
||||
38406,Paris Hilton
|
||||
1226426,Nicky Hilton
|
||||
18329,Maria Schneider
|
||||
4426,Maria Michi
|
||||
147,Michael Madsen
|
||||
82702,Michael Jackson
|
||||
65605,Muhammad Ali
|
||||
47775,Marc Anthony
|
||||
4483,Dustin Hoffman
|
||||
13570,Samuel Goldwyn
|
||||
3417,Tony Goldwyn
|
||||
68402,Barry Navidi
|
||||
5049,John Hurt
|
||||
68381,Thom Eberhardt
|
||||
4053937,Judah Carew
|
||||
4053939,Joe Njenga
|
||||
4053940,Karste Wright
|
||||
1159,Steven Bauer
|
||||
1150,Brian De Palma
|
||||
1151,Martin Bregman
|
||||
7447,Alec Baldwin
|
||||
9560,Ellen Burstyn
|
||||
5682,Anouk Aimée
|
||||
44556,Richard Anconina
|
||||
20234,Fanny Ardant
|
||||
1487,Bob Dylan
|
||||
111714,Al Green
|
||||
165867,Kid Rock
|
||||
1056052,Lee Child
|
||||
500,Tom Cruise
|
||||
106179,Anthony Franciosa
|
||||
10190,Jill St. John
|
||||
5250,Jack Klugman
|
||||
8483,Horton Foote
|
||||
8482,Robert Mulligan
|
||||
6349,Alan J. Pakula
|
||||
8488,Mary Badham
|
||||
8489,Phillip Alford
|
||||
235416,Sarah Snook
|
||||
1281967,Josh McConville
|
||||
1604285,Liv Hewson
|
||||
1105441,Bobbi Salvör Menuez
|
||||
66744,Chaney Kley
|
||||
53286,Richard Karn
|
||||
8184,Mary Kate Schellhardt
|
||||
1028353,John Anthony West
|
||||
1028355,Robert M. Schoch
|
||||
707,Dan Aykroyd
|
||||
26485,Jim Belushi
|
||||
54812,Chevy Chase
|
||||
516,Annette Bening
|
||||
2116053,Maud Guillaumin
|
||||
1119476,Jonathan Kuntz
|
||||
3947315,Mark Eliot
|
||||
4786,Richard Attenborough
|
||||
51816,Paul M. Heller
|
||||
46602,Fred Weintraub
|
||||
14101,John Larroquette
|
||||
18794,Kate Nelligan
|
||||
85139,Nicholas Braun
|
||||
19429,Bruce Lee
|
||||
18897,Jackie Chan
|
||||
51576,Chuck Norris
|
||||
2103203,James B. Nicholson
|
||||
131168,Lee Hoi-Chuen
|
||||
17844,Elke Sommer
|
||||
6263,Hannelore Elsner
|
||||
10254,Mario Adorf
|
||||
15196,David Hemmings
|
||||
46780,Samantha Eggar
|
||||
66884,Emlyn Williams
|
||||
2883,Leif Garrett
|
||||
3011,Linda Manz
|
||||
5147,Ralph Seymour
|
||||
67676,Kenneth More
|
||||
116838,Betsy Drake
|
||||
100787,Patrick Barr
|
||||
1921578,Gaston Rébuffat
|
||||
239398,Maurice Baquet
|
||||
31070,Ryan O'Neal
|
||||
31071,Marisa Berenson
|
||||
2264,Patrick Magee
|
||||
17604,Jeremy Renner
|
||||
418,Robert Patrick
|
||||
138986,Tony Bennett
|
||||
1532769,Nolwenn Leroy
|
||||
1109331,Duffy
|
||||
86449,Christophe Willem
|
||||
64825,Harry Hamlin
|
||||
12646,Terry O'Quinn
|
||||
91332,Dedee Pfeiffer
|
||||
78805,Laura Leighton
|
||||
7180,John Candy
|
||||
14882,Jackie Gleason
|
||||
7503,Red Buttons
|
||||
14639,Mel Brooks
|
||||
14670,Joan Rivers
|
||||
1895,Carl Reiner
|
||||
7172,James Brown
|
||||
1172565,Lesley Gore
|
||||
1572034,Robert Scott Wilson
|
||||
2555,David Proval
|
||||
7004,Paul Sorvino
|
||||
138,Quentin Tarantino
|
||||
2545,Lawrence Bender
|
||||
2144,Tobin Bell
|
||||
2505,James Cromwell
|
||||
1215054,Jerry Rice
|
||||
9248,Nora Ephron
|
||||
146307,Joe Guzaldo
|
||||
7166,Kevin Pollak
|
||||
39770,Adam Roarke
|
||||
34721,Larry Bishop
|
||||
16376,Larry David
|
||||
16377,Jerry Seinfeld
|
||||
1206,Jason Alexander
|
||||
33,Gary Sinise
|
||||
32749,Alex Diakun
|
||||
99,Amanda Plummer
|
||||
6804,Graham Greene
|
||||
69302,Litefoot
|
||||
65529,Irene Bedard
|
||||
101028,Michelle Borth
|
||||
70303,Zach Gilford
|
||||
11064,David Strathairn
|
||||
1238314,Kurt Busch
|
||||
204415,Jimmie Johnson
|
|
954
tunmnlu/task_1/Q1/old/edges.csv
Normal file
954
tunmnlu/task_1/Q1/old/edges.csv
Normal file
@@ -0,0 +1,954 @@
|
||||
source,target
|
||||
2975,6384
|
||||
6384,530
|
||||
6384,1357063
|
||||
6384,40644
|
||||
6384,1779512
|
||||
6384,21127
|
||||
6384,1692944
|
||||
6384,64
|
||||
6384,1776
|
||||
6384,38803
|
||||
6384,20215
|
||||
6384,2130
|
||||
2975,530
|
||||
2975,8349
|
||||
2975,8351
|
||||
2975,8354
|
||||
2975,1107983
|
||||
2975,52057
|
||||
2975,110380
|
||||
2975,18471
|
||||
2975,74611
|
||||
2975,1407498
|
||||
530,529
|
||||
530,532
|
||||
1357063,40644
|
||||
1357063,3894
|
||||
1357063,1892
|
||||
1357063,19498
|
||||
40644,1779512
|
||||
40644,2710
|
||||
40644,4587
|
||||
40644,8691
|
||||
40644,72129
|
||||
40644,189111
|
||||
40644,23964
|
||||
1779512,1357063
|
||||
21127,1692944
|
||||
21127,9827
|
||||
21127,143103
|
||||
21127,21708
|
||||
21127,72983
|
||||
21127,124909
|
||||
21127,4038
|
||||
21127,18992
|
||||
21127,2047
|
||||
21127,4730
|
||||
21127,9464
|
||||
21127,14409
|
||||
64,1776
|
||||
64,1415341
|
||||
64,1267653
|
||||
64,7467
|
||||
64,1519399
|
||||
64,1003
|
||||
64,524
|
||||
64,38803
|
||||
64,3894
|
||||
64,1810
|
||||
64,3895
|
||||
64,958722
|
||||
64,41381
|
||||
64,10980
|
||||
64,10989
|
||||
64,10990
|
||||
64,20215
|
||||
64,2130
|
||||
64,219479
|
||||
64,1101349
|
||||
64,1407495
|
||||
64,3361135
|
||||
64,1812
|
||||
64,2037
|
||||
64,5081
|
||||
64,1892
|
||||
1776,2559324
|
||||
1776,2559325
|
||||
1776,27888
|
||||
1776,2630
|
||||
1776,958722
|
||||
1776,41381
|
||||
1776,38803
|
||||
1776,151007
|
||||
1776,1769
|
||||
1776,19772
|
||||
1776,1
|
||||
1776,7879
|
||||
1776,20215
|
||||
1776,2130
|
||||
1776,1032
|
||||
1776,1006721
|
||||
1776,11483
|
||||
1776,8349
|
||||
1776,8351
|
||||
1776,8354
|
||||
38803,151007
|
||||
38803,5953
|
||||
38803,325
|
||||
38803,3125
|
||||
38803,3084
|
||||
38803,1158
|
||||
38803,3085
|
||||
38803,3087
|
||||
38803,3092
|
||||
20215,2130
|
||||
20215,117669
|
||||
20215,558466
|
||||
20215,61555
|
||||
20215,10017
|
||||
20215,5563
|
||||
20215,26557
|
||||
20215,18688
|
||||
20215,8437
|
||||
20215,589
|
||||
2130,16431
|
||||
2130,2203
|
||||
2130,3026
|
||||
2130,32
|
||||
2130,12132
|
||||
2130,932719
|
||||
2130,2127
|
||||
2130,2128
|
||||
2130,2675
|
||||
8349,8351
|
||||
8349,8354
|
||||
8349,1278399
|
||||
8349,1659326
|
||||
8349,26466
|
||||
8349,18269
|
||||
8349,5606
|
||||
8349,5632
|
||||
8349,1179102
|
||||
8349,11367
|
||||
8349,31028
|
||||
8349,1397846
|
||||
8349,2166741
|
||||
8349,3266
|
||||
8349,36059
|
||||
8349,21010
|
||||
8349,101032
|
||||
8349,98569
|
||||
8349,2080584
|
||||
8349,103835
|
||||
8349,6717
|
||||
8349,928944
|
||||
8349,2022250
|
||||
8349,9979
|
||||
8349,514
|
||||
8349,6193
|
||||
8349,1892
|
||||
8349,2641
|
||||
8349,92029
|
||||
8349,218506
|
||||
8349,2098136
|
||||
8349,2098137
|
||||
8349,2098138
|
||||
8351,8354
|
||||
1107983,52057
|
||||
1107983,110380
|
||||
1107983,181934
|
||||
1107983,496175
|
||||
1107983,1280183
|
||||
1107983,1006651
|
||||
1107983,237876
|
||||
1107983,180659
|
||||
1107983,1165240
|
||||
1107983,2787630
|
||||
1107983,89289
|
||||
1107983,2102583
|
||||
1107983,73988
|
||||
1107983,21111
|
||||
1107983,2803017
|
||||
1107983,2803001
|
||||
1107983,4193575
|
||||
1107983,4193577
|
||||
1107983,4193578
|
||||
1107983,2954
|
||||
1107983,33663
|
||||
1107983,2301996
|
||||
1107983,214317
|
||||
1107983,13716
|
||||
1107983,117180
|
||||
1107983,23626
|
||||
1107983,937663
|
||||
1107983,1931175
|
||||
1107983,12951
|
||||
1107983,2998183
|
||||
1107983,1231277
|
||||
52057,110380
|
||||
52057,60158
|
||||
52057,24810
|
||||
52057,2535
|
||||
52057,225620
|
||||
52057,1683093
|
||||
52057,79538
|
||||
52057,1562353
|
||||
52057,1038
|
||||
52057,4173
|
||||
52057,349
|
||||
110380,4587
|
||||
110380,9780
|
||||
110380,19011
|
||||
110380,146687
|
||||
110380,74266
|
||||
110380,1507609
|
||||
110380,1507612
|
||||
110380,1507613
|
||||
110380,1122373
|
||||
110380,1122374
|
||||
110380,1122375
|
||||
18471,74611
|
||||
18471,1407498
|
||||
18471,1897
|
||||
18471,77896
|
||||
18471,2395
|
||||
18471,1735828
|
||||
18471,53397
|
||||
18471,1224841
|
||||
18471,539
|
||||
18471,111513
|
||||
18471,514
|
||||
18471,6193
|
||||
18471,1892
|
||||
74611,1407498
|
||||
74611,2682390
|
||||
74611,2227
|
||||
74611,4430
|
||||
74611,14837
|
||||
74611,5823
|
||||
74611,3141
|
||||
74611,449538
|
||||
74611,13309
|
||||
74611,1661465
|
||||
1407498,2395
|
||||
1407498,1735828
|
||||
1407498,53397
|
||||
1407498,102786
|
||||
1407498,128550
|
||||
1407498,2320880
|
||||
529,532
|
||||
529,46300
|
||||
529,27889
|
||||
529,1331
|
||||
529,326
|
||||
529,323
|
||||
529,11099
|
||||
532,6384
|
||||
532,2975
|
||||
532,7187
|
||||
532,57371
|
||||
532,3034
|
||||
3894,6968
|
||||
3894,3895
|
||||
3894,1810
|
||||
3894,1892
|
||||
3894,19498
|
||||
3894,11669
|
||||
3894,43120
|
||||
3894,53926
|
||||
3894,34947
|
||||
3894,1262612
|
||||
3894,21200
|
||||
3894,525
|
||||
3894,15556
|
||||
3894,3361135
|
||||
3894,1812
|
||||
3894,131286
|
||||
3894,60634
|
||||
3894,7133
|
||||
3894,15762
|
||||
3894,1160
|
||||
3894,1813
|
||||
1892,2157
|
||||
1892,880
|
||||
1892,1231844
|
||||
1892,1214256
|
||||
1892,19498
|
||||
1892,514
|
||||
1892,6193
|
||||
1892,2037
|
||||
1892,5081
|
||||
1892,31
|
||||
1892,3197
|
||||
1892,12833
|
||||
1892,1810
|
||||
1892,3361135
|
||||
1892,1812
|
||||
1892,10297
|
||||
1892,1813
|
||||
1892,83002
|
||||
1892,21037
|
||||
1892,1800494
|
||||
1892,1775343
|
||||
19498,127712
|
||||
19498,3035
|
||||
19498,527313
|
||||
19498,6193
|
||||
19498,21007
|
||||
19498,234352
|
||||
2710,4587
|
||||
2710,8691
|
||||
2710,869
|
||||
2710,96884
|
||||
2710,1100
|
||||
2710,2713
|
||||
2710,2231
|
||||
2710,1
|
||||
2710,6159
|
||||
2710,2395
|
||||
2710,1735828
|
||||
2710,53397
|
||||
4587,33181
|
||||
4587,63611
|
||||
4587,53574
|
||||
4587,16217
|
||||
4587,9780
|
||||
4587,8691
|
||||
4587,15762
|
||||
4587,1160
|
||||
4587,1813
|
||||
4587,8891
|
||||
4587,44038
|
||||
4587,1121437
|
||||
4587,70243
|
||||
4587,15973
|
||||
4587,16108
|
||||
8691,73475
|
||||
8691,2078350
|
||||
8691,73457
|
||||
8691,543530
|
||||
8691,111946
|
||||
8691,57691
|
||||
8691,343
|
||||
8691,3223
|
||||
8691,74568
|
||||
8691,103
|
||||
8691,16828
|
||||
8691,1897
|
||||
8691,18471
|
||||
8691,77896
|
||||
72129,1851091
|
||||
72129,189111
|
||||
72129,23964
|
||||
72129,3810
|
||||
72129,6431
|
||||
189111,23964
|
||||
23964,1625558
|
||||
23964,112
|
||||
23964,1283
|
||||
9827,143103
|
||||
9827,17606
|
||||
9827,17605
|
||||
9827,75131
|
||||
143103,75131
|
||||
21708,72983
|
||||
21708,124909
|
||||
21708,27442
|
||||
21708,24299
|
||||
21708,5476
|
||||
21708,30721
|
||||
21708,9287
|
||||
21708,70119
|
||||
21708,7502
|
||||
72983,124909
|
||||
72983,86381
|
||||
72983,1012743
|
||||
72983,8767
|
||||
72983,23931
|
||||
72983,121718
|
||||
72983,77003
|
||||
72983,199449
|
||||
72983,819
|
||||
4038,18992
|
||||
4038,2047
|
||||
4038,2222
|
||||
4038,152699
|
||||
4038,4037
|
||||
4038,1269
|
||||
4038,13472
|
||||
4038,13473
|
||||
4038,2607714
|
||||
4038,3896
|
||||
4038,2517086
|
||||
4038,151432
|
||||
4038,3763830
|
||||
4038,133499
|
||||
4038,1724558
|
||||
4038,7904
|
||||
4038,4244
|
||||
4038,13476
|
||||
4038,44301
|
||||
4038,11905
|
||||
4038,38127
|
||||
4038,231318
|
||||
18992,2047
|
||||
18992,2130
|
||||
18992,16431
|
||||
18992,2203
|
||||
2047,1027445
|
||||
2047,1027448
|
||||
2047,155474
|
||||
2047,232449
|
||||
2047,2049
|
||||
2047,11784
|
||||
2047,65398
|
||||
2047,2390
|
||||
2047,58493
|
||||
2047,22860
|
||||
2047,44822
|
||||
2047,1669775
|
||||
2047,5247
|
||||
2047,20904
|
||||
2047,157963
|
||||
2047,74375
|
||||
2047,155890
|
||||
2047,2210813
|
||||
2047,2879828
|
||||
2047,9979
|
||||
2047,9789
|
||||
2047,6449
|
||||
4730,9464
|
||||
4730,14409
|
||||
9464,14409
|
||||
9464,1272970
|
||||
9464,1591305
|
||||
9464,1179187
|
||||
9464,291133
|
||||
9464,61223
|
||||
9464,880
|
||||
9464,73968
|
||||
9464,90633
|
||||
14409,151343
|
||||
14409,11275
|
||||
14409,6199
|
||||
14409,4491
|
||||
14409,14405
|
||||
14409,14406
|
||||
14409,3861945
|
||||
14409,566154
|
||||
14409,1141310
|
||||
1415341,1267653
|
||||
7467,1519399
|
||||
7467,57446
|
||||
7467,215486
|
||||
7467,1161962
|
||||
1003,524
|
||||
1003,39350
|
||||
1003,1722308
|
||||
1003,24501
|
||||
1003,39646
|
||||
524,2179581
|
||||
524,1805442
|
||||
524,3499637
|
||||
524,164004
|
||||
524,26472
|
||||
524,3223
|
||||
524,16828
|
||||
524,103
|
||||
1810,3361135
|
||||
1810,1812
|
||||
1810,3895
|
||||
1810,34947
|
||||
1810,1262612
|
||||
1810,21200
|
||||
3895,1291312
|
||||
3895,2983750
|
||||
3895,6968
|
||||
3895,39998
|
||||
3895,7506
|
||||
3895,9979
|
||||
3895,9789
|
||||
3895,6449
|
||||
3895,290
|
||||
3895,8606
|
||||
3895,1304968
|
||||
3895,10297
|
||||
3895,1813
|
||||
3895,83002
|
||||
3895,834
|
||||
3895,16523
|
||||
3895,19460
|
||||
3895,6952
|
||||
3895,114454
|
||||
3895,10017
|
||||
3895,6193
|
||||
3895,24045
|
||||
3895,3899
|
||||
3895,525
|
||||
3895,15556
|
||||
3895,3361135
|
||||
3895,1812
|
||||
958722,41381
|
||||
41381,20215
|
||||
41381,2130
|
||||
41381,6384
|
||||
10980,10989
|
||||
10980,10990
|
||||
10980,475512
|
||||
10980,56323
|
||||
10980,13636
|
||||
10989,1689289
|
||||
10989,11275
|
||||
10989,10990
|
||||
10990,23659
|
||||
10990,152416
|
||||
10990,83873
|
||||
10990,449538
|
||||
10990,87525
|
||||
10990,7056
|
||||
219479,1101349
|
||||
219479,1407495
|
||||
219479,491896
|
||||
219479,969097
|
||||
219479,3785095
|
||||
1101349,1452124
|
||||
1101349,1364893
|
||||
1101349,1744249
|
||||
1101349,1569717
|
||||
1101349,1407495
|
||||
1101349,31515
|
||||
1101349,1218635
|
||||
1101349,1544086
|
||||
1101349,1997030
|
||||
1101349,89056
|
||||
1101349,1101364
|
||||
1101349,1101343
|
||||
1101349,3358480
|
||||
1101349,3358481
|
||||
1101349,3358482
|
||||
1101349,1101342
|
||||
1101349,1016349
|
||||
1101349,108661
|
||||
1101349,214830
|
||||
1101349,1070445
|
||||
1407495,18471
|
||||
1407495,74611
|
||||
1407495,1407498
|
||||
1407495,974169
|
||||
1407495,1098962
|
||||
1407495,1331457
|
||||
3361135,1812
|
||||
1812,6193
|
||||
1812,103
|
||||
1812,2282
|
||||
1812,2682390
|
||||
1812,2227
|
||||
1812,4430
|
||||
2037,96074
|
||||
2037,4569
|
||||
2037,218984
|
||||
2037,15737
|
||||
2037,1167897
|
||||
2037,5081
|
||||
2037,15488
|
||||
2037,73288
|
||||
2037,1844919
|
||||
2037,658
|
||||
2037,6193
|
||||
2037,24045
|
||||
2037,3899
|
||||
2037,3894
|
||||
2037,1810
|
||||
2037,3895
|
||||
2559324,2559325
|
||||
27888,4784
|
||||
27888,13333
|
||||
27888,2630
|
||||
27888,227
|
||||
27888,40542
|
||||
2630,5048
|
||||
2630,923
|
||||
2630,20718
|
||||
2630,4399
|
||||
2630,3564
|
||||
1769,18517
|
||||
1769,101831
|
||||
1769,205
|
||||
1769,2299
|
||||
1769,19772
|
||||
1769,1
|
||||
1769,7879
|
||||
1769,5953
|
||||
1769,325
|
||||
1769,3125
|
||||
1769,3084
|
||||
1769,1158
|
||||
1769,3085
|
||||
1769,3087
|
||||
1769,3092
|
||||
1,7879
|
||||
1,71538
|
||||
1,3993
|
||||
1,553222
|
||||
1,24343
|
||||
1,1021364
|
||||
1,491
|
||||
1,488
|
||||
1,2231
|
||||
1,6159
|
||||
1,5026
|
||||
1,132305
|
||||
1,18598
|
||||
1,11770
|
||||
1,515
|
||||
1,349
|
||||
1,1032
|
||||
1,1006721
|
||||
1,11483
|
||||
1,4
|
||||
1,3799
|
||||
1,130
|
||||
1,33185
|
||||
1,670
|
||||
1,10930
|
||||
1,2140901
|
||||
1,2
|
||||
1,9979
|
||||
1,9789
|
||||
1,6449
|
||||
7879,15811
|
||||
7879,61416
|
||||
7879,94037
|
||||
7879,7314
|
||||
7879,35219
|
||||
7879,31
|
||||
7879,109255
|
||||
7879,2106
|
||||
7879,146136
|
||||
7879,628
|
||||
7879,608
|
||||
7879,1417
|
||||
7879,1186197
|
||||
7879,110675
|
||||
7879,574290
|
||||
7879,2231
|
||||
7879,6159
|
||||
1032,1130441
|
||||
1032,108650
|
||||
1032,1006721
|
||||
1032,11483
|
||||
1032,380
|
||||
1032,16514
|
||||
1032,1130439
|
||||
1032,2585
|
||||
1032,1044
|
||||
1032,3661
|
||||
1032,5026
|
||||
1032,132305
|
||||
1032,18598
|
||||
1032,3636
|
||||
1032,109410
|
||||
1032,4135
|
||||
1032,1052109
|
||||
1032,1052107
|
||||
1032,1146050
|
||||
1032,11478
|
||||
1032,6193
|
||||
1032,83198
|
||||
1032,101377
|
||||
1032,141
|
||||
1032,8487
|
||||
1032,7046
|
||||
1032,1102449
|
||||
1032,155890
|
||||
1032,2210813
|
||||
1032,2879828
|
||||
1032,190
|
||||
1032,14701
|
||||
1032,6449
|
||||
1032,3264451
|
||||
1032,1034310
|
||||
1032,126750
|
||||
1032,9979
|
||||
1032,9789
|
||||
1032,1038
|
||||
1032,1036
|
||||
1006721,11483
|
||||
1006721,11477
|
||||
1006721,380
|
||||
1006721,4517
|
||||
1006721,1038
|
||||
1006721,1036
|
||||
11483,11477
|
||||
11483,380
|
||||
11483,4517
|
||||
11483,4430
|
||||
11483,1038
|
||||
11483,1036
|
||||
5953,325
|
||||
5953,3125
|
||||
5953,1314108
|
||||
5953,9656
|
||||
5953,61441
|
||||
5953,110068
|
||||
5953,56584
|
||||
5953,2092052
|
||||
5953,2003784
|
||||
5953,1873369
|
||||
5953,6193
|
||||
5953,21007
|
||||
5953,234352
|
||||
325,84534
|
||||
325,9315
|
||||
325,70851
|
||||
325,134
|
||||
325,544016
|
||||
325,62644
|
||||
325,2041
|
||||
325,1740159
|
||||
325,1740160
|
||||
325,1945289
|
||||
325,2191424
|
||||
325,2191425
|
||||
325,1135272
|
||||
325,337
|
||||
325,2689367
|
||||
325,3125
|
||||
325,1549410
|
||||
325,214586
|
||||
325,323
|
||||
325,339
|
||||
325,1776464
|
||||
325,4244
|
||||
325,4238
|
||||
325,37934
|
||||
325,15310
|
||||
325,12207
|
||||
325,154782
|
||||
325,154783
|
||||
325,174875
|
||||
3125,1114225
|
||||
3125,1114226
|
||||
3125,116152
|
||||
3125,116153
|
||||
3125,123448
|
||||
3125,2392722
|
||||
3125,2973752
|
||||
3125,1093165
|
||||
3125,116341
|
||||
3125,128550
|
||||
3125,111946
|
||||
3125,1214377
|
||||
3125,56288
|
||||
3125,1059545
|
||||
3125,37934
|
||||
3125,15310
|
||||
3125,12207
|
||||
3125,32797
|
||||
3125,1193602
|
||||
3125,120615
|
||||
3125,88339
|
||||
3125,116154
|
||||
3125,1795433
|
||||
3125,72208
|
||||
3125,3284
|
||||
3125,18746
|
||||
3125,2240369
|
||||
3125,82280
|
||||
3125,40092
|
||||
3125,21397
|
||||
3125,134
|
||||
3125,3981237
|
||||
3125,104156
|
||||
3125,38406
|
||||
3125,1226426
|
||||
3084,18329
|
||||
3084,4426
|
||||
3084,1158
|
||||
3084,3087
|
||||
3084,3085
|
||||
3084,18269
|
||||
3084,147
|
||||
3084,82702
|
||||
3084,65605
|
||||
3084,47775
|
||||
3084,8349
|
||||
3084,8351
|
||||
3084,8354
|
||||
3084,4483
|
||||
3084,13570
|
||||
3084,3417
|
||||
3084,68402
|
||||
3084,5049
|
||||
3084,68381
|
||||
3084,4053937
|
||||
3084,4053939
|
||||
3084,4053940
|
||||
3084,104156
|
||||
3084,38406
|
||||
3084,1226426
|
||||
1158,1159
|
||||
1158,1160
|
||||
1158,3087
|
||||
1158,3092
|
||||
1158,3085
|
||||
1158,1150
|
||||
1158,1151
|
||||
3085,7447
|
||||
3085,9560
|
||||
3085,3087
|
||||
3085,5682
|
||||
3085,44556
|
||||
3085,20234
|
||||
3085,1487
|
||||
3085,111714
|
||||
3085,165867
|
||||
3085,3092
|
||||
3087,3092
|
||||
3087,1056052
|
||||
3087,500
|
||||
3087,12132
|
||||
3087,2130
|
||||
3087,932719
|
||||
3087,8349
|
||||
3087,8351
|
||||
3087,8354
|
||||
3087,106179
|
||||
3087,10190
|
||||
3087,5250
|
||||
3087,8483
|
||||
3087,8482
|
||||
3087,6349
|
||||
3087,8487
|
||||
3087,8488
|
||||
3087,8489
|
||||
3092,3084
|
||||
117669,558466
|
||||
117669,61555
|
||||
558466,235416
|
||||
558466,1281967
|
||||
558466,61555
|
||||
558466,1604285
|
||||
558466,1105441
|
||||
61555,66744
|
||||
61555,53286
|
||||
61555,8184
|
||||
10017,5563
|
||||
10017,26557
|
||||
10017,1028353
|
||||
10017,1028355
|
||||
10017,6952
|
||||
10017,114454
|
||||
10017,707
|
||||
10017,26485
|
||||
10017,54812
|
||||
10017,4430
|
||||
10017,6449
|
||||
10017,516
|
||||
10017,2116053
|
||||
10017,1119476
|
||||
10017,3947315
|
||||
10017,4786
|
||||
10017,326
|
||||
5563,51816
|
||||
5563,46602
|
||||
5563,26557
|
||||
5563,14101
|
||||
5563,18794
|
||||
5563,85139
|
||||
5563,19429
|
||||
5563,18897
|
||||
5563,51576
|
||||
5563,2103203
|
||||
5563,131168
|
||||
26557,17844
|
||||
26557,6263
|
||||
26557,10254
|
||||
26557,15196
|
||||
26557,46780
|
||||
26557,66884
|
||||
26557,2883
|
||||
26557,3011
|
||||
26557,5147
|
||||
26557,67676
|
||||
26557,116838
|
||||
26557,100787
|
||||
26557,1921578
|
||||
26557,2106
|
||||
26557,239398
|
||||
26557,31070
|
||||
26557,31071
|
||||
26557,2264
|
||||
18688,8437
|
||||
18688,589
|
||||
18688,17604
|
||||
18688,418
|
||||
18688,138986
|
||||
18688,1532769
|
||||
18688,1109331
|
||||
18688,86449
|
||||
8437,64825
|
||||
8437,12646
|
||||
8437,589
|
||||
8437,91332
|
||||
8437,78805
|
||||
8437,7180
|
||||
8437,14882
|
||||
8437,7503
|
||||
8437,14639
|
||||
8437,14670
|
||||
8437,1895
|
||||
8437,22860
|
||||
8437,7172
|
||||
8437,1172565
|
||||
589,1572034
|
||||
589,2555
|
||||
589,7004
|
||||
589,138
|
||||
589,2545
|
||||
589,141
|
||||
589,2144
|
||||
589,2505
|
||||
16431,2203
|
||||
16431,17604
|
||||
16431,1215054
|
||||
3026,32
|
||||
3026,9248
|
||||
3026,7904
|
||||
3026,146307
|
||||
3026,7166
|
||||
3026,39770
|
||||
3026,34721
|
||||
3026,21010
|
||||
3026,6193
|
||||
3026,21007
|
||||
3026,234352
|
||||
3026,16376
|
||||
3026,16377
|
||||
3026,1206
|
||||
3026,4430
|
||||
3026,6449
|
||||
3026,516
|
||||
32,31
|
||||
32,33
|
||||
32,880
|
||||
32,73968
|
||||
32,90633
|
||||
12132,932719
|
||||
12132,32749
|
||||
12132,99
|
||||
12132,6804
|
||||
12132,69302
|
||||
12132,65529
|
||||
12132,101028
|
||||
12132,70303
|
||||
12132,11064
|
||||
12132,73457
|
||||
12132,8691
|
||||
12132,543530
|
||||
932719,1238314
|
||||
932719,204415
|
||||
2127,2128
|
||||
2127,2675
|
||||
2128,2675
|
|
685
tunmnlu/task_1/Q1/old/nodes.csv
Normal file
685
tunmnlu/task_1/Q1/old/nodes.csv
Normal file
@@ -0,0 +1,685 @@
|
||||
id,name
|
||||
2975,Laurence Fishburne
|
||||
6384,Keanu Reeves
|
||||
530,Carrie-Anne Moss
|
||||
1357063,Darrin Prescott
|
||||
40644,Chad Stahelski
|
||||
1779512,Jackson Spidell
|
||||
21127,Bobby Cannavale
|
||||
1692944,Heidi Schreck
|
||||
64,Gary Oldman
|
||||
1776,Francis Ford Coppola
|
||||
38803,Roman Coppola
|
||||
20215,Billy Campbell
|
||||
2130,Cary Elwes
|
||||
8349,Martin Sheen
|
||||
8351,Frederic Forrest
|
||||
8354,Albert Hall
|
||||
1107983,Martin Luther King Jr.
|
||||
52057,Obba Babatundé
|
||||
110380,Colin Powell
|
||||
18471,Anthony Anderson
|
||||
74611,Tracee Ellis Ross
|
||||
1407498,Marsai Martin
|
||||
529,Guy Pearce
|
||||
532,Joe Pantoliano
|
||||
3894,Christian Bale
|
||||
1892,Matt Damon
|
||||
19498,Jon Bernthal
|
||||
2710,James Cameron
|
||||
4587,Halle Berry
|
||||
8691,Zoe Saldaña
|
||||
72129,Jennifer Lawrence
|
||||
189111,Suzanne Collins
|
||||
23964,Gary Ross
|
||||
9827,Rose Byrne
|
||||
143103,Krew Boylan
|
||||
21708,Tomas Milian
|
||||
72983,Manny Pérez
|
||||
124909,Danny Hoch
|
||||
4038,Susan Sarandon
|
||||
18992,Aidan Quinn
|
||||
2047,Danny Glover
|
||||
4730,Emmy Rossum
|
||||
9464,Harry Lennix
|
||||
14409,David Schwimmer
|
||||
1415341,Kazuhiro Tsuji
|
||||
1267653,Chet Zar
|
||||
7467,David Fincher
|
||||
1519399,Erik Messerschmidt
|
||||
1003,Jean Reno
|
||||
524,Natalie Portman
|
||||
1810,Heath Ledger
|
||||
3895,Michael Caine
|
||||
958722,Eiko Ishioka
|
||||
41381,Sadie Frost
|
||||
10980,Daniel Radcliffe
|
||||
10989,Rupert Grint
|
||||
10990,Emma Watson
|
||||
219479,Criss Angel
|
||||
1101349,Steve Aoki
|
||||
1407495,Miles Brown
|
||||
3361135,Peter Kent
|
||||
1812,Michelle Williams
|
||||
2037,Cillian Murphy
|
||||
5081,Emily Blunt
|
||||
2559324,Beth Lane
|
||||
2559325,Lea Madda
|
||||
27888,Raúl Juliá
|
||||
2630,Nastassja Kinski
|
||||
151007,Peter Ramsey
|
||||
1769,Sofia Coppola
|
||||
19772,Paul Rassam
|
||||
1,George Lucas
|
||||
7879,John Lasseter
|
||||
1032,Martin Scorsese
|
||||
1006721,Charles Scorsese
|
||||
11483,Catherine Scorsese
|
||||
5953,Spike Jonze
|
||||
325,Eminem
|
||||
3125,Madonna
|
||||
3084,Marlon Brando
|
||||
1158,Al Pacino
|
||||
3085,James Caan
|
||||
3087,Robert Duvall
|
||||
3092,Diane Keaton
|
||||
117669,Portia Doubleday
|
||||
558466,Alex Russell
|
||||
61555,Haley Ramm
|
||||
10017,Charlton Heston
|
||||
5563,James Coburn
|
||||
26557,Ferdy Mayne
|
||||
18688,Harry Connick Jr.
|
||||
8437,Teri Garr
|
||||
589,Daryl Hannah
|
||||
16431,Sam Elliott
|
||||
2203,Neal McDonough
|
||||
3026,Rob Reiner
|
||||
32,Robin Wright
|
||||
12132,Michael Rooker
|
||||
932719,Jeff Gordon
|
||||
2127,James Wan
|
||||
2128,Leigh Whannell
|
||||
2675,Darren Lynn Bousman
|
||||
1278399,Joseph Steven
|
||||
1659326,Teresa Modnick
|
||||
26466,Caroline Kava
|
||||
18269,Brendan Fraser
|
||||
5606,Sissy Spacek
|
||||
5632,Jack Fisk
|
||||
1179102,Kathleen Kennedy
|
||||
11367,Bradley Whitford
|
||||
31028,Richard Schiff
|
||||
1397846,Craig Barron
|
||||
2166741,Robert A. Baum Jr.
|
||||
3266,Joe Mantegna
|
||||
36059,Joanna Pacula
|
||||
21010,Alexandra Hay
|
||||
101032,Rod McCary
|
||||
98569,Vincent Van Patten
|
||||
2080584,Ben Jorgensen
|
||||
103835,Jeff Monahan
|
||||
6717,James Marshall
|
||||
928944,Coleman Barks
|
||||
2022250,Robert Bly
|
||||
9979,Peter Coyote
|
||||
514,Jack Nicholson
|
||||
6193,Leonardo DiCaprio
|
||||
2641,Martin Landau
|
||||
92029,Gabriel Bologna
|
||||
218506,Gretchen Becker
|
||||
2098136,Brian Becker
|
||||
2098137,Richard Becker
|
||||
2098138,Blase Bonpane
|
||||
181934,Al Sharpton
|
||||
496175,Carmelo Anthony
|
||||
1280183,Coretta Scott King
|
||||
1006651,John Lewis
|
||||
237876,Sarah-Jane Sauvegrain
|
||||
180659,Rosa Parks
|
||||
1165240,Jason Alan Carvell
|
||||
2787630,Valentin Zorin
|
||||
89289,Jesse Jackson
|
||||
2102583,Andrew Cohen
|
||||
73988,Lyndon B. Johnson
|
||||
21111,John F. Kennedy
|
||||
2803017,Arthur John Birch
|
||||
2803001,Haroldson Lafayette Hunt
|
||||
4193575,Maxime Demigné
|
||||
4193577,Gabin Clerc
|
||||
4193578,Tom Chabeau
|
||||
2954,Jeffrey Wright
|
||||
33663,Donald Trump
|
||||
2301996,Mike Pence
|
||||
214317,Ben Bradlee
|
||||
13716,Carl Bernstein
|
||||
117180,Tom Brokaw
|
||||
23626,Liev Schreiber
|
||||
937663,Neil Amdur
|
||||
1931175,Bob Beamon
|
||||
12951,O.J. Simpson
|
||||
2998183,Nicole Brown Simpson
|
||||
1231277,Marcia Clark
|
||||
60158,Shirley Jones
|
||||
24810,Pat Boone
|
||||
2535,Vivica A. Fox
|
||||
225620,Rudolph Moise
|
||||
1683093,Terayle Hill
|
||||
79538,Khalil Kain
|
||||
1562353,Erica Mena
|
||||
1038,Jodie Foster
|
||||
4173,Anthony Hopkins
|
||||
349,Scott Glenn
|
||||
9780,Angela Bassett
|
||||
19011,George W. Bush
|
||||
146687,Tony Blair
|
||||
74266,Dick Cheney
|
||||
1507609,Bob Coen
|
||||
1507612,Francis E. Boyle
|
||||
1507613,Jean Patterson
|
||||
1122373,Marion Barry Jr.
|
||||
1122374,Chuck Brown
|
||||
1122375,Lewis Franklin
|
||||
1897,Bernie Mac
|
||||
77896,Bill Bellamy
|
||||
2395,Whoopi Goldberg
|
||||
1735828,Halle Bailey
|
||||
53397,Christina Aguilera
|
||||
1224841,Mo Willems
|
||||
539,Thomas Lennon
|
||||
111513,Yvette Nicole Brown
|
||||
2682390,Gerd Ludwig
|
||||
2227,Nicole Kidman
|
||||
4430,Sharon Stone
|
||||
14837,Carol Burnett
|
||||
5823,Julie Andrews
|
||||
3141,Marisa Tomei
|
||||
449538,Adele
|
||||
13309,Oprah Winfrey
|
||||
1661465,Lizzo
|
||||
102786,Barack Obama
|
||||
128550,Desmond Tutu
|
||||
2320880,Sundar Pichai
|
||||
46300,Alexander Nathan Etel
|
||||
27889,Stephan Elliott
|
||||
1331,Hugo Weaving
|
||||
326,Kim Basinger
|
||||
323,Curtis Hanson
|
||||
11099,Dante Spinotti
|
||||
7187,Richard Donner
|
||||
57371,Jeff Cohen
|
||||
3034,Corey Feldman
|
||||
6968,Hugh Jackman
|
||||
11669,Jimmy Fallon
|
||||
43120,Andy Dick
|
||||
53926,Jon Heder
|
||||
34947,Kevin Conroy
|
||||
1262612,Neal Adams
|
||||
21200,Will Arnett
|
||||
525,Christopher Nolan
|
||||
15556,Rebecca Hall
|
||||
131286,Mark David
|
||||
60634,Marty Belafsky
|
||||
7133,Max Casella
|
||||
15762,Tara Strong
|
||||
1160,Michelle Pfeiffer
|
||||
1813,Anne Hathaway
|
||||
2157,Robin Williams
|
||||
880,Ben Affleck
|
||||
1231844,Manny Ramírez
|
||||
1214256,Curt Schilling
|
||||
31,Tom Hanks
|
||||
3197,Tom Sizemore
|
||||
12833,Edward Burns
|
||||
10297,Matthew McConaughey
|
||||
83002,Jessica Chastain
|
||||
21037,Prince
|
||||
1800494,Cora Coleman-Dunham
|
||||
1775343,Josh Dunham
|
||||
127712,Matt Ryan
|
||||
3035,Jerry O'Connell
|
||||
527313,Taissa Farmiga
|
||||
21007,Jonah Hill
|
||||
234352,Margot Robbie
|
||||
869,Gale Anne Hurd
|
||||
96884,Al Giddings
|
||||
1100,Arnold Schwarzenegger
|
||||
2713,Linda Hamilton
|
||||
2231,Samuel L. Jackson
|
||||
6159,Ron Howard
|
||||
33181,Jimmy Smits
|
||||
63611,Nickolas Grace
|
||||
53574,Eric Thal
|
||||
16217,Lynn Whitfield
|
||||
8891,John Travolta
|
||||
44038,Nancy Allen
|
||||
1121437,Leslie Felperin
|
||||
70243,Eartha Kitt
|
||||
15973,Julie Newmar
|
||||
16108,Lee Meriwether
|
||||
73475,Adriano Giannini
|
||||
2078350,Tommaso Basili
|
||||
73457,Chris Pratt
|
||||
543530,Dave Bautista
|
||||
111946,Britney Spears
|
||||
57691,Tamra Davis
|
||||
343,Taryn Manning
|
||||
3223,Robert Downey Jr.
|
||||
74568,Chris Hemsworth
|
||||
103,Mark Ruffalo
|
||||
16828,Chris Evans
|
||||
1851091,Josh Silver
|
||||
3810,Javier Bardem
|
||||
6431,Darren Aronofsky
|
||||
1625558,Awkwafina
|
||||
112,Cate Blanchett
|
||||
1283,Helena Bonham Carter
|
||||
17606,Imogen Poots
|
||||
17605,Idris Elba
|
||||
75131,Nash Edgerton
|
||||
27442,Renato Salvatori
|
||||
24299,Jean-Claude Brialy
|
||||
5476,Nino Castelnuovo
|
||||
30721,Madeleine Robinson
|
||||
9287,Robert Blake
|
||||
70119,Catherine Spaak
|
||||
7502,Ernest Borgnine
|
||||
86381,Algenis Perez Soto
|
||||
1012743,Dalisa Alegría
|
||||
8767,Jim Caviezel
|
||||
23931,Mira Sorvino
|
||||
121718,Bill Camp
|
||||
77003,Gavin O'Connor
|
||||
199449,Greg O'Connor
|
||||
819,Edward Norton
|
||||
2222,Beau Bridges
|
||||
152699,James Noble
|
||||
4037,Ron Shelton
|
||||
1269,Kevin Costner
|
||||
13472,Tim Curry
|
||||
13473,Barry Bostwick
|
||||
2607714,Alan Cooke
|
||||
3896,Liam Neeson
|
||||
2517086,Will Hochman
|
||||
151432,Boris McGiver
|
||||
3763830,Jim Forbes
|
||||
133499,Christopher Biggins
|
||||
1724558,Justin Arnold
|
||||
7904,Billy Crystal
|
||||
4244,Lauryn Hill
|
||||
13476,Nell Campbell
|
||||
44301,Cliff DeYoung
|
||||
11905,Sven Nykvist
|
||||
38127,Erland Josephson
|
||||
231318,Melinda Kinnaman
|
||||
1027445,Hedviges Mamudo
|
||||
1027448,Melanie de Vales Rafael
|
||||
155474,Keb' Mo'
|
||||
232449,Yolonda Williams
|
||||
2049,Rubén Blades
|
||||
11784,Tom Atkins
|
||||
65398,Denise Nicholas
|
||||
2390,LeVar Burton
|
||||
58493,Tim Grimm
|
||||
22860,Chuck Berry
|
||||
44822,Starletta DuPois
|
||||
1669775,Lou Ferguson
|
||||
5247,John Fiedler
|
||||
20904,James Hong
|
||||
157963,Loren Avedon
|
||||
74375,Cynthia Rothrock
|
||||
155890,Julie Garfield
|
||||
2210813,Ellen Adler
|
||||
2879828,Joseph Bernard
|
||||
9789,Robert Altman
|
||||
6449,Warren Beatty
|
||||
1272970,Christina Wren
|
||||
1591305,MorningStar Angeline
|
||||
1179187,T'Shaun Barrett
|
||||
291133,Tai Bennett
|
||||
61223,Sharon Brathwaite-Sanders
|
||||
73968,Henry Cavill
|
||||
90633,Gal Gadot
|
||||
151343,David Baddiel
|
||||
11275,Stephen Fry
|
||||
6199,Miriam Margolyes
|
||||
4491,Jennifer Aniston
|
||||
14405,Courteney Cox
|
||||
14406,Lisa Kudrow
|
||||
3861945,Rob Helms
|
||||
566154,Bruce Daniels
|
||||
1141310,Joe Dietl
|
||||
57446,Mark Romanek
|
||||
215486,Fiona Apple
|
||||
1161962,Brian Bell
|
||||
39350,Anémone
|
||||
1722308,Jan Vancoillie
|
||||
24501,Pierre Richard
|
||||
39646,Mireille Darc
|
||||
2179581,Tarek Aylouch
|
||||
1805442,Michael Markiewicz
|
||||
3499637,Nick Garrison
|
||||
164004,Ken Cheeseman
|
||||
26472,Steve Guttenberg
|
||||
1291312,Jürgen Thormann
|
||||
2983750,Peter Garloff
|
||||
39998,Tim McIntire
|
||||
7506,Irwin Allen
|
||||
290,Christopher Plummer
|
||||
8606,Robert Shaw
|
||||
1304968,June Tobin
|
||||
834,Otto Preminger
|
||||
16523,Burgess Meredith
|
||||
19460,Saul Bass
|
||||
6952,Charlie Sheen
|
||||
114454,BJ Davis
|
||||
24045,Joseph Gordon-Levitt
|
||||
3899,Ken Watanabe
|
||||
475512,Ellie Kemper
|
||||
56323,Tina Fey
|
||||
13636,Jane Krakowski
|
||||
1689289,Justine Lupe
|
||||
23659,Will Ferrell
|
||||
152416,Murray Bartlett
|
||||
83873,June Diane Raphael
|
||||
87525,Alan Carr
|
||||
7056,Emma Thompson
|
||||
491896,Brie Garcia
|
||||
969097,Nikki Garcia
|
||||
3785095,Kathy Colace
|
||||
1452124,Jason Derulo
|
||||
1364893,Iggy Azalea
|
||||
1744249,Kygo
|
||||
1569717,Martin Garrix
|
||||
31515,Mark Cuban
|
||||
1218635,Gary Vaynerchuk
|
||||
1544086,Min Yoon-gi
|
||||
1997030,Halsey
|
||||
89056,David Guetta
|
||||
1101364,Josh Wink
|
||||
1101343,Carl Cox
|
||||
3358480,Alan Walker
|
||||
3358481,Margrethe Alida
|
||||
3358482,Au/Ra
|
||||
1101342,Sven Väth
|
||||
1016349,Norman Cook
|
||||
108661,Chester Bennington
|
||||
214830,Mike Shinoda
|
||||
1070445,Brad Delson
|
||||
974169,Jenna Ortega
|
||||
1098962,Dove Cameron
|
||||
1331457,Sofia Carson
|
||||
2282,Ben Kingsley
|
||||
96074,Leslie Feist
|
||||
4569,David Fox
|
||||
218984,Johnny Ward
|
||||
15737,Helen McCrory
|
||||
1167897,Natasha O'Keeffe
|
||||
15488,Ken Loach
|
||||
73288,Michael McElhatton
|
||||
1844919,Sam McGovern
|
||||
658,Alfred Molina
|
||||
4784,Laura Dern
|
||||
13333,Vanessa Redgrave
|
||||
227,William Hurt
|
||||
40542,Héctor Babenco
|
||||
5048,Harry Dean Stanton
|
||||
923,Dean Stockwell
|
||||
20718,Claude Berri
|
||||
4399,Timothy Burrill
|
||||
3564,Hervé de Luze
|
||||
18517,Kim Gordon
|
||||
101831,Thurston Moore
|
||||
205,Kirsten Dunst
|
||||
2299,Josh Hartnett
|
||||
71538,Dave Filoni
|
||||
3993,Dennis Muren
|
||||
553222,Bill Moyers
|
||||
24343,Peter Mayhew
|
||||
1021364,Joseph Campbell
|
||||
491,John Williams
|
||||
488,Steven Spielberg
|
||||
5026,Akira Kurosawa
|
||||
132305,Nobuhiko Obayashi
|
||||
18598,Ishirō Honda
|
||||
11770,John Carpenter
|
||||
515,Glenn Close
|
||||
4,Carrie Fisher
|
||||
3799,Billy Dee Williams
|
||||
130,Kenny Baker
|
||||
33185,Jeremy Bulloch
|
||||
670,Ben Burtt
|
||||
10930,Irvin Kershner
|
||||
2140901,Gary Kurtz
|
||||
2,Mark Hamill
|
||||
15811,John Musker
|
||||
61416,Peter Del Vecho
|
||||
94037,Bruno Bozzetto
|
||||
7314,Nick Park
|
||||
35219,Corey Burton
|
||||
109255,Leonard Maltin
|
||||
2106,Walt Disney
|
||||
146136,Bernice Hansen
|
||||
628,Isao Takahata
|
||||
608,Hayao Miyazaki
|
||||
1417,Toshio Suzuki
|
||||
1186197,Steve Alpert
|
||||
110675,Jerry Beck
|
||||
574290,Dave Bossert
|
||||
1130441,Robert Sklar
|
||||
108650,Alain Silver
|
||||
380,Robert De Niro
|
||||
16514,Robert Chartoff
|
||||
1130439,Drew Casper
|
||||
2585,Eric Clapton
|
||||
1044,Michael Chapman
|
||||
3661,Thelma Schoonmaker
|
||||
3636,Paul Newman
|
||||
109410,Joanne Woodward
|
||||
4135,Robert Redford
|
||||
1052109,Harry Styles
|
||||
1052107,Niall Horan
|
||||
1146050,Zayn Malik
|
||||
11478,Lorraine Bracco
|
||||
83198,Allan Arkush
|
||||
101377,Paul Bartel
|
||||
141,David Carradine
|
||||
8487,Gregory Peck
|
||||
7046,Cecilia Peck
|
||||
1102449,Veronique Peck
|
||||
190,Clint Eastwood
|
||||
14701,Carroll Baker
|
||||
3264451,Ann Adachi-Tasch
|
||||
1034310,Margaret Bodde
|
||||
126750,Serge Bromberg
|
||||
1036,Cybill Shepherd
|
||||
11477,Ray Liotta
|
||||
4517,Joe Pesci
|
||||
1314108,FatLip
|
||||
9656,Johnny Knoxville
|
||||
61441,Rick Kosick
|
||||
110068,Ryan Dunn
|
||||
56584,Bam Margera
|
||||
2092052,Ryder McLaughlin
|
||||
2003784,Na-kel Smith
|
||||
1873369,Aramis Hudson
|
||||
84534,Dido
|
||||
9315,Marilyn Manson
|
||||
70851,Jack Black
|
||||
134,Jamie Foxx
|
||||
544016,D12
|
||||
62644,50 Cent
|
||||
2041,Dr. Dre
|
||||
1740159,Marky Bass
|
||||
1740160,Jeff Bass
|
||||
1945289,Denaun Porter
|
||||
2191424,Courtney Butcher
|
||||
2191425,Pj Jacokes
|
||||
1135272,Skylar Grey
|
||||
337,Proof
|
||||
2689367,Swifty McVay
|
||||
1549410,Dead Prez
|
||||
214586,Melle Mel
|
||||
339,Brian Grazer
|
||||
1776464,Stretch Armstrong
|
||||
4238,Common
|
||||
37934,André 3000
|
||||
15310,Anthony Kiedis
|
||||
12207,Kylie Minogue
|
||||
154782,Pat Benatar
|
||||
154783,Neil Giraldo
|
||||
174875,Carly Simon
|
||||
1114225,Kevin Antunes
|
||||
1114226,Monte Pittman
|
||||
116152,Donna DeLory
|
||||
116153,Niki Haris
|
||||
123448,Stuart Price
|
||||
2392722,Steve Sidelnyk
|
||||
2973752,Erika Belle
|
||||
1093165,Christopher Ciccone
|
||||
116341,Bill Clinton
|
||||
1214377,Felicia Culotta
|
||||
56288,Alysson Paradis
|
||||
1059545,Sidney Duteil
|
||||
32797,Arianne Phillips
|
||||
1193602,Gia Coppola
|
||||
120615,Tom Ford
|
||||
88339,Kevin Stea
|
||||
116154,Luis Camacho
|
||||
1795433,Oliver Crumes
|
||||
72208,Alicia Keys
|
||||
3284,Bruce Springsteen
|
||||
18746,Stevie Wonder
|
||||
2240369,Bert Stern
|
||||
82280,Louis Armstrong
|
||||
40092,Twiggy
|
||||
21397,Dennis Rodman
|
||||
3981237,Shirley Rodman
|
||||
104156,Ann-Marie MacDonald
|
||||
38406,Paris Hilton
|
||||
1226426,Nicky Hilton
|
||||
18329,Maria Schneider
|
||||
4426,Maria Michi
|
||||
147,Michael Madsen
|
||||
82702,Michael Jackson
|
||||
65605,Muhammad Ali
|
||||
47775,Marc Anthony
|
||||
4483,Dustin Hoffman
|
||||
13570,Samuel Goldwyn
|
||||
3417,Tony Goldwyn
|
||||
68402,Barry Navidi
|
||||
5049,John Hurt
|
||||
68381,Thom Eberhardt
|
||||
4053937,Judah Carew
|
||||
4053939,Joe Njenga
|
||||
4053940,Karste Wright
|
||||
1159,Steven Bauer
|
||||
1150,Brian De Palma
|
||||
1151,Martin Bregman
|
||||
7447,Alec Baldwin
|
||||
9560,Ellen Burstyn
|
||||
5682,Anouk Aimée
|
||||
44556,Richard Anconina
|
||||
20234,Fanny Ardant
|
||||
1487,Bob Dylan
|
||||
111714,Al Green
|
||||
165867,Kid Rock
|
||||
1056052,Lee Child
|
||||
500,Tom Cruise
|
||||
106179,Anthony Franciosa
|
||||
10190,Jill St. John
|
||||
5250,Jack Klugman
|
||||
8483,Horton Foote
|
||||
8482,Robert Mulligan
|
||||
6349,Alan J. Pakula
|
||||
8488,Mary Badham
|
||||
8489,Phillip Alford
|
||||
235416,Sarah Snook
|
||||
1281967,Josh McConville
|
||||
1604285,Liv Hewson
|
||||
1105441,Bobbi Salvör Menuez
|
||||
66744,Chaney Kley
|
||||
53286,Richard Karn
|
||||
8184,Mary Kate Schellhardt
|
||||
1028353,John Anthony West
|
||||
1028355,Robert M. Schoch
|
||||
707,Dan Aykroyd
|
||||
26485,Jim Belushi
|
||||
54812,Chevy Chase
|
||||
516,Annette Bening
|
||||
2116053,Maud Guillaumin
|
||||
1119476,Jonathan Kuntz
|
||||
3947315,Mark Eliot
|
||||
4786,Richard Attenborough
|
||||
51816,Paul M. Heller
|
||||
46602,Fred Weintraub
|
||||
14101,John Larroquette
|
||||
18794,Kate Nelligan
|
||||
85139,Nicholas Braun
|
||||
19429,Bruce Lee
|
||||
18897,Jackie Chan
|
||||
51576,Chuck Norris
|
||||
2103203,James B. Nicholson
|
||||
131168,Lee Hoi-Chuen
|
||||
17844,Elke Sommer
|
||||
6263,Hannelore Elsner
|
||||
10254,Mario Adorf
|
||||
15196,David Hemmings
|
||||
46780,Samantha Eggar
|
||||
66884,Emlyn Williams
|
||||
2883,Leif Garrett
|
||||
3011,Linda Manz
|
||||
5147,Ralph Seymour
|
||||
67676,Kenneth More
|
||||
116838,Betsy Drake
|
||||
100787,Patrick Barr
|
||||
1921578,Gaston Rébuffat
|
||||
239398,Maurice Baquet
|
||||
31070,Ryan O'Neal
|
||||
31071,Marisa Berenson
|
||||
2264,Patrick Magee
|
||||
17604,Jeremy Renner
|
||||
418,Robert Patrick
|
||||
138986,Tony Bennett
|
||||
1532769,Nolwenn Leroy
|
||||
1109331,Duffy
|
||||
86449,Christophe Willem
|
||||
64825,Harry Hamlin
|
||||
12646,Terry O'Quinn
|
||||
91332,Dedee Pfeiffer
|
||||
78805,Laura Leighton
|
||||
7180,John Candy
|
||||
14882,Jackie Gleason
|
||||
7503,Red Buttons
|
||||
14639,Mel Brooks
|
||||
14670,Joan Rivers
|
||||
1895,Carl Reiner
|
||||
7172,James Brown
|
||||
1172565,Lesley Gore
|
||||
1572034,Robert Scott Wilson
|
||||
2555,David Proval
|
||||
7004,Paul Sorvino
|
||||
138,Quentin Tarantino
|
||||
2545,Lawrence Bender
|
||||
2144,Tobin Bell
|
||||
2505,James Cromwell
|
||||
1215054,Jerry Rice
|
||||
9248,Nora Ephron
|
||||
146307,Joe Guzaldo
|
||||
7166,Kevin Pollak
|
||||
39770,Adam Roarke
|
||||
34721,Larry Bishop
|
||||
16376,Larry David
|
||||
16377,Jerry Seinfeld
|
||||
1206,Jason Alexander
|
||||
33,Gary Sinise
|
||||
32749,Alex Diakun
|
||||
99,Amanda Plummer
|
||||
6804,Graham Greene
|
||||
69302,Litefoot
|
||||
65529,Irene Bedard
|
||||
101028,Michelle Borth
|
||||
70303,Zach Gilford
|
||||
11064,David Strathairn
|
||||
1238314,Kurt Busch
|
||||
204415,Jimmie Johnson
|
|
0
tunmnlu/task_1/Q1/prompts.md
Normal file
0
tunmnlu/task_1/Q1/prompts.md
Normal file
19
tunmnlu/task_1/Q1/run.sh
Normal file
19
tunmnlu/task_1/Q1/run.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
|
||||
python ./Q1_ans.py &
|
||||
python ./Q1_ref.py &
|
||||
|
||||
wait
|
||||
|
||||
|
||||
echo " 888 "
|
||||
echo " 888 "
|
||||
echo " 888 "
|
||||
echo " .d88b. 888 888 "
|
||||
echo "d88''88b888 .88P "
|
||||
echo "888 888888888K "
|
||||
echo "Y88..88P888 "88b "
|
8
tunmnlu/task_1/Q1/test.sh
Normal file
8
tunmnlu/task_1/Q1/test.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
|
||||
|
||||
docker compose up -d
|
||||
docker compose exec -it test bash
|
Reference in New Issue
Block a user