Skip to content

Commit e417312

Browse files
committed
added datasets, scoring, task, parser
1 parent 7d3e971 commit e417312

File tree

7 files changed

+251087
-1
lines changed

7 files changed

+251087
-1
lines changed

data/a.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
H 3 cat beach sun
3+
V 2 selfie smile
4+
V 2 garden selfie
5+
H 2 garden cat

data/b.txt

Lines changed: 80001 additions & 0 deletions
Large diffs are not rendered by default.

data/c.txt

Lines changed: 1001 additions & 0 deletions
Large diffs are not rendered by default.

data/d.txt

Lines changed: 90001 additions & 0 deletions
Large diffs are not rendered by default.

data/e.txt

Lines changed: 80001 additions & 0 deletions
Large diffs are not rendered by default.

main.py

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,82 @@
11
import numpy as np
22
import math
33

4+
filename = 'data/{}.txt'.format('a')
5+
6+
with open(filename) as f_in:
7+
content = f_in.read().split("\n")[:-1]
8+
9+
10+
def eval_output(output_data):
11+
"""
12+
ex. output_data
13+
[
14+
[
15+
[1, ["a", "b"]]
16+
],
17+
[
18+
[2, ["c", "b"]]
19+
],
20+
[
21+
[3, ["a", "c"]],
22+
[4, ["b", "d"]]
23+
],
24+
[
25+
[5, ["c", "d"]]
26+
],
27+
[
28+
[6, ["a", "c"]],
29+
[7, ["c", "d"]]
30+
]
31+
]
32+
"""
33+
score = 0
34+
prev_slide_tags = []
35+
for slide in output_data:
36+
slide_tags = []
37+
for image in slide:
38+
slide_tags += image[1]
39+
slide_tags = set(slide_tags)
40+
common = len(slide_tags.intersection(prev_slide_tags))
41+
in_previous_only = len([t for t in prev_slide_tags if t not in slide_tags])
42+
in_current_only = len([t for t in slide_tags if t not in prev_slide_tags])
43+
minimum = min(common, in_current_only, in_previous_only)
44+
45+
prev_slide_tags = slide_tags
46+
score += minimum
47+
# print("Common:", common)
48+
# print("In previous only:", in_previous_only)
49+
# print("In current only:", in_current_only)
50+
# print("Min:", minimum)
51+
52+
print()
53+
return score
54+
55+
56+
# print("Score:", eval_output([[[1, ["a", "b"]]], [[2, ["c", "b"]]], [[3, ["a", "c"]], [4, ["b", "d"]]], [[5, ["c", "d"]]], [[6, ["a", "c"]], [7, ["c", "d"]]]]))
57+
58+
59+
def create_output_file(output_data):
60+
# ex. output_data = [[1], [2], [3, 4], [5], [6, 7]]
61+
with open(filename.replace('data', 'out'), "w") as f_out:
62+
f_out.write(str(len(output_data)) + '\n')
63+
[f_out.write(' '.join([str(x) for x in slide]) + '\n') for slide in output_data]
64+
65+
66+
class Image:
67+
def __init__(self, image_id, orientation, tags):
68+
self.id = image_id
69+
self.orientation = orientation
70+
self.tags = sorted(tags)
71+
72+
def __str__(self):
73+
return "<Image {}: Orientation: {}, Tags: {}>".format(self.id, self.orientation, self.tags)
74+
75+
476
if __name__ == '__main__':
5-
print("HASHCODE 2019")
77+
print("HASHCODE 2019!\n")
78+
79+
images = [Image(content.index(c)-1, c.split(" ")[0], c.split(" ")[2:]) for c in content[1:]]
80+
print(len(images), "images loaded")
81+
[print(i) for i in images]
82+
# create_output_file([[1], [2], [3, 4], [5], [6, 7]])

photo_slideshow.pdf

147 KB
Binary file not shown.

0 commit comments

Comments
 (0)