Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _buildrelationindex(self):
#print('building relation index...', file=sys.stderr)
freltypes = PrettyList(x for x in XMLCorpusView(self.abspath("frRelation.xml"),
'frameRelations/frameRelationType',
self._handle_framerelationtype_elt))
self._freltyp_idx = {}
self._frel_idx = {}
self._frel_f_idx = defaultdict(set)
self._ferel_idx = {}
for freltyp in freltypes:
self._freltyp_idx[freltyp.ID] = freltyp
for frel in freltyp.frameRelations:
supF = frel.superFrame = frel[freltyp.superFrameName] = Future((lambda fID: lambda: self.frame_by_id(fID))(frel.supID))
subF = frel.subFrame = frel[freltyp.subFrameName] = Future((lambda fID: lambda: self.frame_by_id(fID))(frel.subID))
self._frel_idx[frel.ID] = frel
self._frel_f_idx[frel.supID].add(frel.ID)
self._frel_f_idx[frel.subID].add(frel.ID)
for ferel in frel.feRelations:
ferel.superFrame = supF
ferel.subFrame = subF
ferel.superFE = Future((lambda fer: lambda: fer.superFrame.FE[fer.superFEName])(ferel))
ferel.subFE = Future((lambda fer: lambda: fer.subFrame.FE[fer.subFEName])(ferel))
self._ferel_idx[ferel.ID] = ferel
#print('...done building relation index', file=sys.stderr)
self._frel_f_idx = defaultdict(set)
self._ferel_idx = {}
for freltyp in freltypes:
self._freltyp_idx[freltyp.ID] = freltyp
for frel in freltyp.frameRelations:
supF = frel.superFrame = frel[freltyp.superFrameName] = Future((lambda fID: lambda: self.frame_by_id(fID))(frel.supID))
subF = frel.subFrame = frel[freltyp.subFrameName] = Future((lambda fID: lambda: self.frame_by_id(fID))(frel.subID))
self._frel_idx[frel.ID] = frel
self._frel_f_idx[frel.supID].add(frel.ID)
self._frel_f_idx[frel.subID].add(frel.ID)
for ferel in frel.feRelations:
ferel.superFrame = supF
ferel.subFrame = subF
ferel.superFE = Future((lambda fer: lambda: fer.superFrame.FE[fer.superFEName])(ferel))
ferel.subFE = Future((lambda fer: lambda: fer.subFrame.FE[fer.subFEName])(ferel))
self._ferel_idx[ferel.ID] = ferel
#print('...done building relation index', file=sys.stderr)
self._frel_idx = {}
self._frel_f_idx = defaultdict(set)
self._ferel_idx = {}
for freltyp in freltypes:
self._freltyp_idx[freltyp.ID] = freltyp
for frel in freltyp.frameRelations:
supF = frel.superFrame = frel[freltyp.superFrameName] = Future((lambda fID: lambda: self.frame_by_id(fID))(frel.supID))
subF = frel.subFrame = frel[freltyp.subFrameName] = Future((lambda fID: lambda: self.frame_by_id(fID))(frel.subID))
self._frel_idx[frel.ID] = frel
self._frel_f_idx[frel.supID].add(frel.ID)
self._frel_f_idx[frel.subID].add(frel.ID)
for ferel in frel.feRelations:
ferel.superFrame = supF
ferel.subFrame = subF
ferel.superFE = Future((lambda fer: lambda: fer.superFrame.FE[fer.superFEName])(ferel))
ferel.subFE = Future((lambda fer: lambda: fer.subFrame.FE[fer.subFEName])(ferel))
self._ferel_idx[ferel.ID] = ferel
#print('...done building relation index', file=sys.stderr)
frinfo['definition'] = self._strip_tags(sub.text)
elif sub.tag.endswith('FE') and 'FE' not in ignorekeys:
feinfo = self._handle_fe_elt(sub)
frinfo['FE'][feinfo.name] = feinfo
feinfo['frame'] = frinfo # backpointer
elif sub.tag.endswith('FEcoreSet') and 'FEcoreSet' not in ignorekeys:
coreset = self._handle_fecoreset_elt(sub)
# assumes all FEs have been loaded before coresets
frinfo['FEcoreSets'].append(PrettyList(frinfo['FE'][fe.name] for fe in coreset))
elif sub.tag.endswith('lexUnit') and 'lexUnit' not in ignorekeys:
luentry = self._handle_framelexunit_elt(sub)
if luentry['status'] in self._bad_statuses:
# problematic LU entry; ignore it
continue
luentry['frame'] = frinfo
luentry['subCorpus'] = Future((lambda lu: lambda: self._lu_file(lu))(luentry))
frinfo['lexUnit'][luentry.name] = luentry
if not self._lu_idx:
self._buildluindex()
self._lu_idx[luentry.ID] = luentry
elif sub.tag.endswith('semType') and 'semTypes' not in ignorekeys:
semtypeinfo = self._load_xml_attributes(AttrDict(), sub)
frinfo['semTypes'].append(self.semtype(semtypeinfo.ID))
frinfo['frameRelations'] = self.frame_relations(frame=frinfo)
# resolve 'requires' and 'excludes' links between FEs of this frame
for fe in frinfo.FE.values():
if fe.requiresFE:
name, ID = fe.requiresFE.name, fe.requiresFE.ID
fe.requiresFE = frinfo.FE[name]
assert fe.requiresFE.ID==ID
def _buildrelationindex(self):
#print('building relation index...', file=sys.stderr)
freltypes = PrettyList(x for x in XMLCorpusView(self.abspath("frRelation.xml"),
'frameRelations/frameRelationType',
self._handle_framerelationtype_elt))
self._freltyp_idx = {}
self._frel_idx = {}
self._frel_f_idx = defaultdict(set)
self._ferel_idx = {}
for freltyp in freltypes:
self._freltyp_idx[freltyp.ID] = freltyp
for frel in freltyp.frameRelations:
supF = frel.superFrame = frel[freltyp.superFrameName] = Future((lambda fID: lambda: self.frame_by_id(fID))(frel.supID))
subF = frel.subFrame = frel[freltyp.subFrameName] = Future((lambda fID: lambda: self.frame_by_id(fID))(frel.subID))
self._frel_idx[frel.ID] = frel
self._frel_f_idx[frel.supID].add(frel.ID)
self._frel_f_idx[frel.subID].add(frel.ID)
for ferel in frel.feRelations:
ferel.superFrame = supF
ferel.subFrame = subF
ferel.superFE = Future((lambda fer: lambda: fer.superFrame.FE[fer.superFEName])(ferel))
ferel.subFE = Future((lambda fer: lambda: fer.subFrame.FE[fer.subFEName])(ferel))
self._ferel_idx[ferel.ID] = ferel
#print('...done building relation index', file=sys.stderr)