Skip to content

Commit 53639fa

Browse files
committed
Merge branch 'master' into dev_partitions
2 parents 6f5e0b0 + a3ba4c7 commit 53639fa

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

paramgenerator/generateparams.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,23 @@
1414
def findNameParameters(names, amount = 100):
1515
srtd = sorted(names,key=lambda x: -x[1])
1616
res = []
17+
hist = {}
1718
for t in srtd:
18-
if t[1] > 100 and t[1] < 150:
19-
res.append(t[0])
19+
if t[1] not in hist:
20+
hist[t[1]] = []
21+
hist[t[1]].append(t[0])
22+
counts = sorted([i for i in hist.iterkeys()])
23+
24+
mid = len(counts)/2
25+
i = mid
26+
while counts[i] - counts[mid] < 0.1 * counts[mid]:
27+
res.extend([name for name in hist[counts[i]]])
28+
i += 1
29+
i = mid - 1
30+
while counts[mid] - counts[i] < 0.1 * counts[mid]:
31+
res.extend([name for name in hist[counts[i]]])
32+
i -= 1
33+
2034
return res
2135

2236
class JSONSerializer:

paramgenerator/readfactors.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ def load(factorFiles, friendFiles):
104104
for i in range(nameCount):
105105
line = f.readline().split(",")
106106
name = line[0]
107+
try:
108+
name.decode('ascii')
109+
except UnicodeEncodeError:
110+
continue
111+
107112
if not name in names:
108113
names[name] = 0
109114
names[name] += int(line[1])

0 commit comments

Comments
 (0)