@@ -0,0 +1,1988 @@
+#!/usr/bin/python%0A# -*- coding: utf-8 -*-%0A%0Afrom semcplogic.dataset import Dataset%0Afrom semcplogic.cpmodel import TableResultInterpreter%0Afrom semcplogic.cpcompiler import CPCompiler, ProblogExample%0Afrom semcplogic.problogresult import GnuplotDrawer%0Aimport pprint%0A%0A#We use %22breaks%22 because break is a reserved keyword in problog%0A#We add the probabilities here, but they get removed on compiling%0Acpcode = %22%22%220.8 : breaks %3C-- throws(mary).%0A0.6 : breaks %3C-- throws(john).%0A0.5 : throws(mary) %3C-- true.%0A1 : throws(john) %3C-- true.%0A%22%22%22.split(%22%5Cn%22)%0A%0Acc = CPCompiler()%0A%0Adata = %5B%5D%0A#Two ideas that don't work%0A#i = 0%0A#for i in xrange(i+1,i+1+23):%0A#  data.append(ProblogExample(i,%22throws(mary),throws(john),breaks%22))%0A#for i in xrange(i+1,i+1+2):%0A#  data.append(ProblogExample(i,%22throws(mary),throws(john)%22))%0A#for i in xrange(i+1,i+1+15):%0A#  data.append(ProblogExample(i,%22throws(john),breaks%22))%0A#for i in xrange(i+1,i+1+10):%0A#  data.append(ProblogExample(i,%22throws(john)%22))%0A%0A#i = 0%0A#for i in xrange(i+1,i+1+23):%0A#  data.append(ProblogExample(i,%22throws(mary),throws(john),breaks%22))%0A#for i in xrange(i+1,i+1+2):%0A#  data.append(ProblogExample(i,%22throws(mary),throws(john),problog_not(breaks)%22))%0A#for i in xrange(i+1,i+1+15):%0A#  data.append(ProblogExample(i,%22problog_not(throws_mary),throws(john),breaks%22))%0A#for i in xrange(i+1,i+1+10):%0A#  data.append(ProblogExample(i,%22problog_not(throws_mary),throws(john),problog_not(breaks)%22))%0A%0A#To make it work, be sure the proofs only contain positive information%0A#if necessary, marginalize variables%0Adata.append(ProblogExample(0,%22breaks%22,weight=0.76))%0Adata.append(ProblogExample(1,%22throws(mary)%22,weight=0.5))%0Adata.append(ProblogExample(2,%22throws(john)%22,weight=1))%0Adata.append(ProblogExample(3,%22throws(john),throws(mary),breaks%22,weight=0.46))%0A#We give the weights, so don't calculate them%0Acc.weight=False%0A%0Arunmodel = cc.compileCode(cpcode,otherexamples=data)%0Arunmodel.iterations = 10%0Aresult = runmodel.run()%0Ag = GnuplotDrawer()%0Ag.draw(result)%0Aimport pdb;pdb.set_trace()

Add example of CP-logic parameter learning