def _read_Arg(node): sup = on_single_element(node, (), _read_Sup, 'sup') attribution = on_single_element( node, (), _read_Attribution, 'attribution') return ty.Arg(selection=_read_Selection(node), attribution=(None if attribution is () else attribution), sup=(None if sup is () else sup))
def _read_ExplicitRelationFeatures(node): attribution = on_single_element( node, None, _read_Attribution, 'attribution') connhead = on_single_element( node, None, _read_Connective, 'connhead') return ty.ExplicitRelationFeatures(attribution=attribution, connhead=connhead)
def _read_Attribution(node): attr = node.attrib selection = on_single_element(node, (), _read_Selection, 'selection') return ty.Attribution(polarity=attr['polarity'], determinacy=attr['determinacy'], type=attr['type'], source=attr['source'], selection=None if selection is () else selection)
def _read_Attribution(node): attr = node.attrib selection = on_single_element(node, (), _read_Selection, 'selection') return ty.Attribution(polarity = attr['polarity'], determinacy = attr['determinacy'], type = attr['type'], source = attr['source'], selection = None if selection is () else selection)
def _read_AltLexRelationFeatures(node): attribution = on_single_element(node, None, _read_Attribution, 'attribution') attr = node.attrib semclass1_ = attr['semclass1'] semclass2_ = attr.get('semclass2', None) # optional semclass1 = _read_SemClass(semclass1_) semclass2 = _read_SemClass(semclass2_) if semclass2_ else None return ty.AltLexRelationFeatures(attribution = attribution, semclass1 = semclass1, semclass2 = semclass2)
def _read_ImplicitRelationFeatures(node): connectives = node.findall('connective') if len(connectives) == 0: raise EduceXmlException('Was expecting at least one connective (got none)') elif len(connectives) > 2: raise EduceXmlException('Was expecting no more than two connectives (got %d)' % len(connectives)) attribution = on_single_element(node, None, _read_Attribution, 'attribution') connective1 = _read_Connective(connectives[0]) connective2 = _read_Connective(connectives[1]) if len(connectives) == 2 else None return ty.ImplicitRelationFeatures(attribution = attribution, connective1 = connective1, connective2 = connective2)
def _read_Arg(node): sup = on_single_element(node, (), _read_Sup, 'sup') attribution = on_single_element(node, (), _read_Attribution, 'attribution') return ty.Arg(selection=_read_Selection(node), attribution=None if attribution is () else attribution, sup=None if sup is () else sup)
def _read_Selection(node): attr = node.attrib return ty.Selection(span=_read_SpanList(attr['spanList']), gorn=_read_GornAddressList(attr['gornList']), text=on_single_element(node, None, lambda x: x.text, 'text'))
def _read_ExplicitRelationFeatures(node): attribution = on_single_element(node, None, _read_Attribution, 'attribution') connhead = on_single_element(node, None, _read_Connective, 'connhead') return ty.ExplicitRelationFeatures(attribution=attribution, connhead=connhead)
def get_one(name, default, ctx=None): f = lambda n: read_node(n, ctx) return on_single_element(node, default, f, name)
def _read_Selection(node): attr = node.attrib return ty.Selection(span = _read_SpanList(attr['spanList']), gorn = _read_GornAddressList(attr['gornList']), text = on_single_element(node, None, lambda x:x.text, 'text'))