import sys
import math
import re
import timeit
import random
#Let's start with where you want your output file to be written to:
outputFile = '20.txt'
# list of lists: each list is a list of candidate types, each for one type of input
candTypes = [['1','0'],['01','10'],['100','010','001']]
# let's keep a list of input types around for safekeeping too
inputTypes = ['1syll','2syll','3syll']
# Ok, now: give me a list of numbers, indicating how many of each candidate to win for each input type
inputFreqs = [[1000,0],[0,1000],[20,980,0]]
# And let's just hard code in the violation profiles while we're at it
# Constraints: Align-Ft-R, Align-Ft-L, Nonfin, Iamb, Trochee, haveStress
# So, candidates we're actually considering are:
# (1) - a trochee, 0, (01), (10), (10)0, 0(10), 0(01)
candidates = ["Align-ft-R","Align-ft-L","Nonfin-Ft","Iamb","Trochee","haveStress"]
candViol = [[[0,0,1,1,0,0],[0,0,0,0,0,1]],[[0,0,1,0,1,0],[0,0,1,1,0,0]],[[1,0,0,1,0,0],[0,1,1,1,0,0],[0,1,1,0,1,0]]]
tableaux={} #empty dictionary
for i in range(len(inputTypes)):
for c in range(len(candTypes[i])):
for n in range(inputFreqs[i][c]):
tableau = {}
for cand in range(len(candTypes[i])):
prob = 1 if cand == c else 0
tabProb = random.random()*100 #for randomly assigned frequency
tabProb = 1 # for equal frequency
tableau[candTypes[i][cand]]=[prob]+[tabProb]+candViol[i][cand]
tableaux[inputTypes[i]+'_'+str(c)+'_'+str(n)] = tableau
print tableaux
with open(outputFile,'w') as f:
f.write('\t'.join(['input', 'output', 'probability','tab.prob','Align-Ft-R','Align-Ft-L','Nonfin-Ft','Iamb','Trochee','haveStress']) )
for tab in tableaux:
for cand in tableaux[tab]:
f.write('\n')
f.write('\t'.join([tab]+[cand]+[str(x) for x in tableaux[tab][cand]]))