''' Updated 7/8/2002 by Seth Russell ''' # ------------------------------------------------------- # writing # ------------------------------------------------------- production={} # sail is set to the instance of the sailor agent # by writing('html') from sailor sail = 'none' sp = ' ' nl = '
' tab = '    ' bold = '' boldEnd = '' row = '' endRow = '' production['space']= lambda: ' ' production['nl']= lambda: '
' production['tab']= lambda: '    ' production['bold']= lambda: '' production['boldEnd']= lambda: '' production['node']= lambda: \ sa('nodeStart') +\ topicFor('localName') +\ sa('typeRow') +\ predicatesFor('slot') +\ sa('submitRow') +\ sa('nodeEnd') production['nodeStart']= lambda: \ '
' +\ '' def topicFor(copula): if sail.ve(copula): return sa('topicRow') else: return sa('annonTopic') production['topicRow']= lambda: \ '' production['annonTopic']= lambda: \ '' production['typeRow'] = lambda: \ '' def predicatesFor(copula): r='' if not sail.ve(copula): return r logic=1 while logic: if not sail.emptyObject(): r=r+sa('predicateRow') logic=sail.nextObject() return r production['predicateRow']= lambda: \ '' production['submitRow'] = lambda: \ ' \n' production['nodeEnd']= lambda: '
' + \ ckUri(sail.objectName()) + sa('tab') + \ ' \n' +\ '
' + \ hidden('groNode','') +\ '
type' +\ hidden('groPredicate','type') +\ hidden('groObject',ckUri(sail.nodeName())) +\ '' + \ ckUri(sail.nodeName()) +\ '
' + \ hidden('groPredicate',ckUri(sail.objectName())) +\ ckUri(sail.objectName()) +\ '' + \ ' \n' +\ '
' + \ '' + \ '
' def hidden(xname,xvalue): if xvalue==None: v='' else: v=xvalue r=' \n' return r ## Routines necessary to function def sa(xproduction): # execuite this grammar's expression in this module # bound to 'say' in sailor agent if production.has_key(xproduction): sail.mem() r=production[xproduction]() sail.remem() return r else: return 'No production "%s" in %s grammar.' % (xproduction, sail.sayingGrammar) def ckUri(s): # cant't have <...> characters in HTML markup s=s.replace('<','<') s=s.replace('>','>') return s ## Routines necessary to function class say: def __init__(self, other): self.sail=other def sa(self,xproduction): global sail sail=self.sail return sa(xproduction) class read: def __init__(self, other): global sail sail=other def readDoc(self, doc): pass def readText(self,text): pass def processText(self,text): pass