-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputReader.py
More file actions
41 lines (30 loc) · 1.07 KB
/
InputReader.py
File metadata and controls
41 lines (30 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from photo import Photo;
import collections;
class InputReader:
# tags_counter = collections.Counter();
# orientation_counter = collections.Counter();
def __init__(self, path: str) -> None:
self.photos = {}
# print(f'Read input {path}')
file = open(path, 'r')
photo_id = 0
first_line = True
for line in file:
line = line.strip()
# print(line)
if first_line:
first_line = False
else:
line_splited = list(line.split(' '))
orientation_line = line_splited.pop(0)
orientation = 0
if orientation_line == 'V':
orientation = 1
number_tags = line_splited.pop(0)
tags = set(line_splited)
self.photos[photo_id] = Photo(photo_id, orientation, tags)
photo_id += 1
# self.orientation_counter[orientation] += 1
# for tag in tags:
# self.tags_counter[tag] += 1
file.close()