sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) from pythonlib import semantic as sm from pythonlib import attack from pythonlib import sysf from pythonlib import crand inputform = "topic-folder,cl-file,cl-floder,zipf,stype[0(tfidf)/1(tfidf2)/2(lsa)/3(lda)],output-floder" if len(sys.argv) != 7: print "input:" + inputform sys.exit(1) outf = sys.argv[6] + '/sim-' + '-'.join( map(lambda x: x.strip('/').split('/')[-1], sys.argv[2:-1])) fout = sysf.logger(outf, inputform) otype = 0 if sys.argv[6] == 'stdout': otype = 1 def vecof(lines, a, wtol, kk): vec = np.zeros(kk) for line in lines: line = line.strip('\n') vec = vec + a[:, wtol[line]] return vec stype = int(sys.argv[5]) zipf = float(sys.argv[4])
import subprocess import sys from os import path sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) ) from pythonlib import sysf inputform = "command,loops,output-floder" if len(sys.argv) != 4: print "input:" + inputform sys.exit(1) outf = sys.argv[3]+'/loop-'+'-'.join(map(lambda x:x.strip('/').split('/')[-1],sys.argv[1:-1])) fout = sysf.logger(outf,inputform) comm = sys.argv[1].split() for i in range(len(comm)): if comm[i][0] == '~': comm[i] = path.expanduser(comm[i]) elif comm[i][0] == '.': comm[i] = path.abspath(comm[i]) loops = int(sys.argv[2]) for i in range(loops): if subprocess.call(comm) != 0: sys.exit(1)