-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperiments.py
More file actions
55 lines (37 loc) · 1.41 KB
/
experiments.py
File metadata and controls
55 lines (37 loc) · 1.41 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import argparse, sys
from main import Handler
from collections import defaultdict
def count_tags(handler):
tags = defaultdict(int)
for photos in handler.photos:
for tag in photos.tags:
tags[tag] += 1
values = sorted([(value, key) for (key, value) in tags.items()], reverse=True)
return values
def group_quantities(pairs):
c = defaultdict(int)
for pair in pairs:
c[pair[0]] += 1
return sorted(c.items(), reverse=True)
def not_useful(handler):
c = 0
for photo in handler.photos:
if photo.horizontal and (photo.tags) == 1:
c += 1
return c
filenames = ["a_example.txt", "b_lovely_landscapes.txt", "c_memorable_moments.txt", "d_pet_pictures.txt", "e_shiny_selfies.txt"]
if __name__ == "__main__":
for filename in filenames:
print("\n" + filename + "\n")
filename = "data/" + filename
handler = Handler(filename)
tag_count = count_tags(handler)
print(count_tags(handler)[:100])
groups = group_quantities(tag_count)
print(groups[:100])
#not_useful_count = len(list(filter(lambda x: x[0] == 1, groups)))
print("not useful: %d" % not_useful(handler))
print("tags count: %d" % len(tag_count))
print("photos count: %d" % len(handler.photos))
print("hphotos count: %d" % len(handler.hphotos))
print("vphotos count: %d" % len(handler.vphotos))