-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
93 lines (80 loc) · 2.02 KB
/
Copy pathconfig.py
File metadata and controls
93 lines (80 loc) · 2.02 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from faker import Faker
fake = Faker()
siteConfig = {
'siteCount': 10
}
dbConfig = {
'user' : 'root',
'host' : 'localhost',
'db' : 'test',
'charset': 'latin1'
}
postsPopulatorConfig = {
'postsCount': 60000,
'batchSize' : 5000
}
tagsPopulatorConfig = {
'tagsCount': 100000,
'batchSize': 10000
}
relationGeneratorConfig = {
'batchSize': 5000
}
rankGeneratorConfig = {
'batchSize': 5000
}
fakeText = ""
def choice(weighted_choices):
choices, weights = zip(*weighted_choices)
cumdist = list(accumulate(weights))
x = random() * cumdist[-1]
weightedChoice = choices[bisect(cumdist, x)]
return(weightedChoice)
def specialChoice():
specialPostWeights = [
(1,.1),
(0,.9)
]
return choice(specialPostWeights)
def postTypeChoice():
postTypeWeights = [
('normal', .6),
('ecommerce', .044),
('slideshow', .044),
('video', .044),
('duplicate', .044),
('branded_club', .044),
('brand_article', .044),
('brand_article_video', .044),
('longform', .044),
('reposted_slideshow', .044)
]
return choice(postTypeWeights)
def countryChoice(result):
countryWeights = [('ES',.25),('US',.25),('MX',.25),('CO',.25),('NONE',3)]
ES = 0
US = 0
MX = 0
CO = 0
for countries in range(4):
countryWeightedChoice = choice(countryWeights)
if (countryWeightedChoice == 'ES'):
ES = 1
elif (countryWeightedChoice == 'US'):
US = 1
elif (countryWeightedChoice == 'MX'):
MX = 1
elif (countryWeightedChoice == 'CO'):
CO = 1
result = (ES, US, MX, CO)
if result == (0, 0, 0, 0):
result = countryChoice(result)
return result
def process():
global fakeText
postsPopulatorConfig['postsCount'] //= siteConfig['siteCount']
fakeText = fake.text(max_nb_chars = 1000000)
from bisect import bisect
from itertools import accumulate
from random import random
process()