summaryrefslogtreecommitdiff
path: root/unbiasedFunctions.py
diff options
context:
space:
mode:
authorssstvinc2 <sstvinc2@gmail.com>2017-03-09 09:38:57 -0500
committerssstvinc2 <sstvinc2@gmail.com>2017-03-09 09:38:57 -0500
commita596eb07939b8e653355be0020f0a7d8c0ee2d80 (patch)
tree5c36379ffc2411e3aab56a8a64edd2b8a16c9fef /unbiasedFunctions.py
parentf8c6b0084e7d0928121d4c05d3b1f47b10c303c7 (diff)
Reworked Guardian
Diffstat (limited to 'unbiasedFunctions.py')
-rw-r--r--unbiasedFunctions.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/unbiasedFunctions.py b/unbiasedFunctions.py
index 4d2019c..950e16d 100644
--- a/unbiasedFunctions.py
+++ b/unbiasedFunctions.py
@@ -6,7 +6,7 @@ import re
#take in a url and delimiters, return twitter card
-def buildArticle(url, sourceName):#, titleDelStart, titleDelEnd, imgDelStart, imgDelEnd):
+def buildArticle(url, sourceName, encoding=None):#, titleDelStart, titleDelEnd, imgDelStart, imgDelEnd):
debugging=False
if debugging:
@@ -124,15 +124,20 @@ def buildOutput(newsSourceArr):
#set the random order for sources
h1RandomSources=random.sample(range(len(newsSourceArr)), 4)
+
#For h2s and h3s, select N random sources (can repeat), then
#a non-repetitive random article from within
h2RandomPairs=[]
while len(h2RandomPairs) < 6:
x=random.sample(range(len(newsSourceArr)), 1)[0]
- y=random.sample(range(len(newsSourceArr[x].h2Arr)), 1)[0]
- pair=[x,y]
- if not pair in h2RandomPairs:
- h2RandomPairs.append(pair)
+ if len(newsSourceArr[x].h2Arr) > 0:
+ y=random.sample(range(len(newsSourceArr[x].h2Arr)), 1)[0]
+ pair=[x,y]
+ if not pair in h2RandomPairs:
+ h2RandomPairs.append(pair)
+ else:
+ print('\n\n@@@@\nNo H2 stories in '+newsSourceArr[x].name+'\n@@@@\n\n')
+
h3RandomPairs=[]
while len(h3RandomPairs) < 12:
x=random.sample(range(len(newsSourceArr)), 1)[0]