Permalink
Browse files

script for generating human verification

  • Loading branch information...
1 parent b30a8db commit 2eeda12337d1ed8db916b5b8f9e8b8cdcb5ff6a3 @cathywu committed Jan 18, 2012
Showing with 51 additions and 0 deletions.
  1. +51 −0 human.py
View
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+import random
+from random import randrange
+import numpy
+from numpy.random import shuffle
+import os
+
+tests = 10 # number of test subjects
+n = 6 # number of reviews per test subject
+
+def random_insert(lst, item):
+ lst.insert(randrange(len(lst)+1), item)
+
+def get_id(cls, size=6, chars="QWERTYIOPASDFGHJKZXCVBNM"):
+ if cls == 1:
+ # L marks positive
+ special="L"
+ else:
+ # U marks negative
+ special="U"
+ lst = [random.choice(chars) for x in range(size)]
+ random_insert(lst, special)
+ return ''.join(lst)
+
+rev = numpy.arange(2000)
+shuffle(rev)
+print rev
+
+w = open("human.txt",'w')
+pos_files = os.listdir("pos")
+neg_files = os.listdir("neg")
+
+for r in rev:
+ if r >= 1000:
+ r = r - 1000
+ directory = "pos"
+ tag = get_id(1)
+ f = open("%s/%s" % (directory,pos_files[r])).read()
+ else:
+ directory = "neg"
+ tag = get_id(0)
+ f = open("%s/%s" % (directory,neg_files[r])).read()
+
+ w.write(f)
+ w.write("\n\n%s%s===========================================================================\n\n" % (tag,r))
+w.close()
+
+
+
+

0 comments on commit 2eeda12

Please sign in to comment.