def semi_rel2reldict(pairs, window=5, trace=False):
 result = []
 while (len(pairs) > 2):
  reldict = defaultdict(str)
  reldict['lcon'] = _join(pairs[0][0][(- window):])
  reldict['subjclass'] = pairs[0][1].label()
  reldict['subjtext'] = _join(pairs[0][1].leaves())
  reldict['subjsym'] = list2sym(pairs[0][1].leaves())
  reldict['filler'] = _join(pairs[1][0])
  reldict['untagged_filler'] = _join(pairs[1][0], untag=True)
  reldict['objclass'] = pairs[1][1].label()
  reldict['objtext'] = _join(pairs[1][1].leaves())
  reldict['objsym'] = list2sym(pairs[1][1].leaves())
  reldict['rcon'] = _join(pairs[2][0][:window])
  if trace:
   print(('(%s(%s, %s)' % (reldict['untagged_filler'], reldict['subjclass'], reldict['objclass'])))
  result.append(reldict)
  pairs = pairs[1:]
 return result

def semi_rel2reldict ( pairs , window = 5 , trace = False ) : result = [ ] while ( len ( pairs ) > 2 ) : reldict = defaultdict ( str ) reldict [ 'lcon' ] = _join ( pairs [ 0 ] [ 0 ] [ ( - window ) : ] ) reldict [ 'subjclass' ] = pairs [ 0 ] [ 1 ] . label ( ) reldict [ 'subjtext' ] = _join ( pairs [ 0 ] [ 1 ] . leaves ( ) ) reldict [ 'subjsym' ] = list2sym ( pairs [ 0 ] [ 1 ] . leaves ( ) ) reldict [ 'filler' ] = _join ( pairs [ 1 ] [ 0 ] ) reldict [ 'untagged_filler' ] = _join ( pairs [ 1 ] [ 0 ] , untag = True ) reldict [ 'objclass' ] = pairs [ 1 ] [ 1 ] . label ( ) reldict [ 'objtext' ] = _join ( pairs [ 1 ] [ 1 ] . leaves ( ) ) reldict [ 'objsym' ] = list2sym ( pairs [ 1 ] [ 1 ] . leaves ( ) ) reldict [ 'rcon' ] = _join ( pairs [ 2 ] [ 0 ] [ : window ] ) if trace : print ( ( '(%s(%s, %s)' % ( reldict [ 'untagged_filler' ] , reldict [ 'subjclass' ] , reldict [ 'objclass' ] ) ) ) result . append ( reldict ) pairs = pairs [ 1 : ] return result
converts the pairs generated by tree2semi_rel into a reldict: a dictionary which stores information about the subject and object nes plus the filler between them .