minor assignment fix
Browse files- nba_tracking_data_15_16.py +37 -37
nba_tracking_data_15_16.py
CHANGED
@@ -174,46 +174,46 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
|
|
174 |
def _generate_examples(self, filepaths, split):
|
175 |
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
176 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
177 |
-
for link in
|
178 |
-
with open(link, encoding="utf-8") as
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
}
|
214 |
}
|
215 |
}
|
216 |
}
|
|
|
217 |
|
218 |
|
219 |
# for key, row in enumerate(fp):
|
|
|
174 |
def _generate_examples(self, filepaths, split):
|
175 |
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
176 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
177 |
+
for link in filepaths:
|
178 |
+
with open(link, encoding="utf-8") as fp:
|
179 |
+
|
180 |
+
game_id = json.load(fp)["gameid"]
|
181 |
+
game_date = json.load(fp)["gamedate"]
|
182 |
+
for event in json.load(fp)["events"]:
|
183 |
+
event_id = event["eventId"]
|
184 |
+
for moment in event["moments"]:
|
185 |
+
for element in moment:
|
186 |
+
quarter = element[0]
|
187 |
+
game_clock = element[2]
|
188 |
+
shot_clock = element[3]
|
189 |
+
ball_coords = element[5][0][2:]
|
190 |
+
for position in element[5][1:]:
|
191 |
+
team_id = position[0]
|
192 |
+
player_id = position[1]
|
193 |
+
x = position[2]
|
194 |
+
y = position[3]
|
195 |
+
z = position[4]
|
196 |
+
|
197 |
+
yield game_id, {
|
198 |
+
"gameid": game_id,
|
199 |
+
"gamedate": game_date,
|
200 |
+
"events": {
|
201 |
+
"eventid": event_id,
|
202 |
+
"moments": {
|
203 |
+
"quarter": quarter,
|
204 |
+
"game_clock": game_clock,
|
205 |
+
"shot_clock": shot_clock,
|
206 |
+
"ball_coordinates": ball_coords,
|
207 |
+
"player_coordinates": {
|
208 |
+
"teamid": team_id,
|
209 |
+
"playerid": player_id,
|
210 |
+
"x": x,
|
211 |
+
"y": y,
|
212 |
+
"z": z
|
|
|
213 |
}
|
214 |
}
|
215 |
}
|
216 |
+
}
|
217 |
|
218 |
|
219 |
# for key, row in enumerate(fp):
|