def FL(F,w,target): # from CEH'08, Def.5 on p.5 ok = [] for c in F: cw = odot(c,w) accepted = cky.accepts(target,cw) # print 'For FL, oracle says ',accepted,':',cw if accepted: ok.append(c) return ok
P0 = [('S','DP','TP'), ('DP','D','NP'), ('DP','D','N'), ('NP','N','PP'), ('PP','P','DP'), ('N','A','N'), ('NP','A','NP'), ('TP','T','VP'), ('VP','VP','PP'), ('VP','V','V2P'), ('V2P','DP','PP') ] print 'checking sample with target grammar...' for w in sample0: if cky.accepts((PL0,P0),w): print "Accepted by target grammar :",w else: print "Rejected by target grammar :",w t0 = time.time() (PL,P) = iil(sample0,(PL0,P0)) t1 = time.time() print t1 - t0, "seconds" ckyCBFG.prettyGrammar((PL,P)) for w in sample0: if ckyCBFG.ckyChart((PL,P),w): print "Accepted by learner's grammar :",w else: