#NEWLINE# def _pretty_frame( frame ) : #NEWLINE# #INDENT# '\n    Helper function for pretty-printing a frame.\n\n    :param frame: The frame to be printed.\n    :type frame: AttrDict\n    :return: A nicely formated string representation of the frame.\n    :rtype: str\n    ' #NEWLINE# outstr = '' #NEWLINE# outstr += 'frame ({0.ID}): {0.name}\n\n' . format ( frame ) #NEWLINE# outstr += '[definition]\n' #NEWLINE# outstr += ( _pretty_longstring ( frame . definition , '  ' ) + '\n' ) #NEWLINE# outstr += '[semTypes] {0} semantic types\n' . format ( len ( frame . semTypes ) ) #NEWLINE# outstr += ( ( ( '  ' * ( len ( frame . semTypes ) > 0 ) ) + ', ' . join ( ( '{0}({1})' . format ( x . name , x . ID ) for x in frame . semTypes ) ) ) + ( '\n' * ( len ( frame . semTypes ) > 0 ) ) ) #NEWLINE# outstr += '\n[frameRelations] {0} frame relations\n' . format ( len ( frame . frameRelations ) ) #NEWLINE# outstr += ( ( '  ' + '\n  ' . join ( ( repr ( frel ) for frel in frame . frameRelations ) ) ) + '\n' ) #NEWLINE# outstr += '\n[lexUnit] {0} lexical units\n' . format ( len ( frame . lexUnit ) ) #NEWLINE# lustrs = [ ] #NEWLINE# for ( luName , lu ) in sorted ( frame . lexUnit . items ( ) ) : #NEWLINE# #INDENT# tmpstr = '{0} ({1})' . format ( luName , lu . ID ) #NEWLINE# lustrs . append ( tmpstr ) #NEWLINE# #UNINDENT# outstr += '{0}\n' . format ( _pretty_longstring ( ', ' . join ( lustrs ) , prefix = '  ' ) ) #NEWLINE# outstr += '\n[FE] {0} frame elements\n' . format ( len ( frame . FE ) ) #NEWLINE# fes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( feName , fe ) in sorted ( frame . FE . items ( ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# fes [ fe . coreType ] . append ( '{0} ({1})' . format ( feName , fe . ID ) ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# fes [ fe . coreType ] = [ ] #NEWLINE# fes [ fe . coreType ] . append ( '{0} ({1})' . format ( feName , fe . ID ) ) #NEWLINE# #UNINDENT# #UNINDENT# for ct in sorted ( fes . keys ( ) , key = ( lambda ct2 : [ 'Core' , 'Core-Unexpressed' , 'Peripheral' , 'Extra-Thematic' ] . index ( ct2 ) ) ) : #NEWLINE# #INDENT# outstr += '{0:>16}: {1}\n' . format ( ct , ', ' . join ( sorted ( frame [ ct ] ) ) ) #NEWLINE# #UNINDENT# outstr += '\n[FEcoreSets] {0} frame element core sets\n' . format ( len ( frame . FEcoreSets ) ) #NEWLINE# outstr += ( ( '  ' + '\n  ' . join ( ( ', ' . join ( [ x . name for x in coreSet ] ) for coreSet in frame . FEcoreSets ) ) ) + '\n' ) #NEWLINE# return outstr