def run(data_size): print "Running ", data_size # We store the top 100 from each run hypset = FiniteBestSet(TOP_COUNT, max=True) # initialize the data data = generate_data(data_size) # starting hypothesis -- here this generates at random learner = GriceanQuantifierLexicon(make_my_hypothesis, my_weight_function) # We will defautly generate from null the grammar if no value is specified for w in target.all_words(): learner.set_word(w) # populate the finite sample by running the sampler for this many steps for x in mh_sample(learner, data, SAMPLES, skip=0): hypset.push(x, x.posterior_score) return hypset
show_baseline_distribution(TESTING_SET) print "\n\n" # intialize a learner lexicon, at random h0 = GriceanQuantifierLexicon(make_my_hypothesis, my_weight_function) for w in target.all_words(): h0.set_word(w) # We will defautly generate from null the grammar if no value is specified ### sample the target data data = generate_data(300) ### Update the target with the data target.compute_likelihood(data) print h0 #### Now we have built the data, so run MCMC for h in mh_sample(h0, data, 10000000, skip=0): sstr = str(h) sstr = re.sub("[_ ]", "", sstr) sstr = re.sub("presup", u"\u03BB A B . presup", sstr) print h.posterior_score, "\t", h.prior, "\t", h.likelihood, "\t", target.likelihood, "\n", sstr, "\n\n" # for t in data: # print h(t.utterance, t.context), t
print "\n\n" # intialize a learner lexicon, at random h0 = GriceanQuantifierLexicon(make_my_hypothesis, my_weight_function) for w in target.all_words(): h0.set_word( w ) # We will defautly generate from null the grammar if no value is specified ### sample the target data data = generate_data(300) ### Update the target with the data target.compute_likelihood(data) print h0 #### Now we have built the data, so run MCMC for h in mh_sample(h0, data, 10000000, skip=0): sstr = str(h) sstr = re.sub("[_ ]", "", sstr) sstr = re.sub("presup", u"\u03BB A B . presup", sstr) print h.posterior_score, "\t", h.prior, "\t", h.likelihood, "\t", target.likelihood, "\n", sstr, "\n\n" #for t in data: #print h(t.utterance, t.context), t