def check ( vtb , ts , kl=None ): """ lookup method for unit testing arguments: vtb - target vocabulary table ts - text as list of chars kl - length of text to use as key """ lts = len(ts) if kl == None or kl > lts: kl = lts rs = vtb.lookUp(ts,kl) # check for possible vocabulary matches print 'full text=' , '<' + u''.join(ts) + '>' , if len(rs) == 0: # any vocabulary entries found? print 'FOUND NONE' else: print 'FOUND' , len(rs) print '' for r in rs: # if found, note each entry print '=' , unicode(r.vem) # show each match print ' ' , r.nspan , 'chars matched, endings included' if r.suffx != '': print ' ending=' , '[' + r.suffx + ']' # print 'generative semantics' showCode(r.vem.gen.logic) print '' print '--'
def check(vtb, ts, kl=None): """ lookup method for unit testing arguments: vtb - target vocabulary table ts - text as list of chars kl - length of text to use as key """ lts = len(ts) if kl == None or kl > lts: kl = lts rs = vtb.lookUp(ts, kl) # check for possible vocabulary matches # print ( 'full text=' , '<' + ''.join(ts) + '>' , end=' ' ) if len(rs) == 0: # any vocabulary entries found? print('FOUND NONE') else: print('FOUND', len(rs)) print() for r in rs: # if found, note each entry print('=', str(r.vem)) # show each match print(' ', r.nspan, 'chars matched, endings included') if r.suffx != '': print(' ending=', '[' + r.suffx + ']') # print ( 'generative semantics' ) showCode(r.vem.gen.logic) print() print('--')
def __str__(self): """ show procedure logic arguments: self """ generativeDefiner.showCode(self.logic)
def __unicode__ ( self ): """ show procedure logic arguments: self """ generativeDefiner.showCode(self.logic)
def showProcedures(r): """ show semantic procedures for rule arguments: r - rule """ print ' ** cognitive' if r.cogs != None: cognitiveDefiner.showCode(r.cogs.logic) print ' ** generative' if r.gens != None: generativeDefiner.showCode(r.gens.logic) print ''
def dumpSubprocedures(index, full, pxl=None): """ show standalone procedures arguments: index - procedure index full - flag for full dump pxl - semantic subprocedure index returns: number of calls to unknown subprocedures """ print() print("Semantic Subprocedures") print("----------------------") noe = 0 lps = index.keys() for p in lps: print() print(p) if index[p] == None: print('** undefined!') elif full: noe += generativeDefiner.showCode(index[p].logic, pxl) return noe
def showProcedures ( r ): """ show semantic procedures for rule arguments: r - rule """ print ' ** cognitive' if r.cogs != None: cognitiveDefiner.showCode(r.cogs.logic) print ' ** generative' if r.gens != None: generativeDefiner.showCode(r.gens.logic) print ''
def check ( vtb , ts , kl ): """ lookup method for unit testing """ vs = vtb.lookUp(ts,kl) # check for possible vocabulary matches if len(vs) == 0: # any vocabulary entries found? print ts[:kl] , 'NOT FOUND' else: print ts[:kl] , 'FOUND' , len(vs) for v in vs: # if found, note each entry rec = v[0] vrs = v[1] print '=' , unicode(rec) # show each match print ' ' , vrs.mtchl , 'chars matched, with' , vrs.dropn , 'extra' print ' suffix=' , '[-' + vrs.suffx + ']' , 'restore=' , vrs.restr print 'generative semantics' showCode(rec.gen.logic) print '--'
def dumpSubprocedures ( index , full ): """ show standalone procedures arguments: index - procedure index full - flag for full dump """ print "" print "Semantic Subprocedures" print "----------------------" lps = index.keys() for p in lps: print "" print p if full: generativeDefiner.showCode(index[p].logic)
def check ( vtb , ts , kl=None ): """ lookup method for unit testing """ if kl == None: kl = len(ts) rs = vtb.lookUp(ts,kl) # check for possible vocabulary matches print 'in text' , '"' + u''.join(ts) + '"' , if len(rs) == 0: # any vocabulary entries found? print 'FOUND NONE' else: print 'FOUND' , len(rs) print '' for r in rs: # if found, note each entry print '=' , unicode(r.vem) # show each match print ' ' , r.nspan , 'chars matched, endings included' if r.suffx != '': print ' ending=' , '[' + r.suffx + ']' # print 'generative semantics' showCode(r.vem.gen.logic) print '' print '--'
def dumpSubprocedures(index, full): """ show standalone procedures arguments: index - procedure index full - flag for full dump """ print "" print "Semantic Subprocedures" print "----------------------" lps = index.keys() for p in lps: print "" print p if index[p] == None: print '** undefined!' elif full: generativeDefiner.showCode(index[p].logic)
def showProcedures(r, pxl=None): """ show semantic procedures for rule arguments: r - rule pxl - semantic subprocedure index returns: number of calls to undefined subprocedures """ noe = 0 print(' ** cognitive') if r.cogs != None: cognitiveDefiner.showCode(r.cogs.logic) print(' ** generative') if r.gens != None: noe += generativeDefiner.showCode(r.gens.logic, pxl) print() return noe
for srcn in args: # test all specified input files ctx.clearLocalStack() # reset context ctx.clearBuffers() print "------------" , srcn inp = ellyDefinitionReader.EllyDefinitionReader(srcn) if inp.error != None: # check if input readable print >> sys.stderr, "cannot read procedure definition" , srcn print >> sys.stderr, inp.error continue for ln in inp.buffer: # echo input file print ln print '' gp = GenerativeProcedure(stb,inp) # compile procedure print '*CODE*' if gp.logic != None: showCode(gp.logic) # dump procedure logic else: print 'null logic' continue res = gp.doRun(ctx,phr) # run the procedure print '----' print 'run status=' , res # show status print '----' frame.showBuffers() # show output buffers print "------------" print len(args),'test file(s)'
for srcn in args: # test all specified input files ctx.clearLocalStack() # reset context ctx.clearBuffers() print "------------" , srcn inp = ellyDefinitionReader.EllyDefinitionReader(srcn) if inp.error != None: # check if input readable print >> sys.stderr, "cannot read procedure definition" , srcn print >> sys.stderr, inp.error continue for ln in inp.buffer: # echo input file print ln print '' gp = GenerativeProcedure(stb,inp) # compile procedure print '*CODE*' if gp.logic != None: showCode(gp.logic) # dump procedure logic else: print 'no logic' continue res = gp.doRun(ctx,phr) # run the procedure print '----' print 'run status=' , res # show status print '----' frame.showBuffers() # show output buffers print "------------" print len(args),'test file(s)'