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_Relation(node): tag = node.tag if tag == 'explicitRelation': return _read_ExplicitRelation(node) elif tag == 'implicitRelation': return _read_ImplicitRelation(node) elif tag == 'altLexRelation': return _read_AltLexRelation(node) elif tag == 'entityRelation': return _read_EntityRelation(node) elif tag == 'noRelation': return _read_NoRelation(node) else: raise EduceXmlException("Don't know how to read relation with name %s" % tag)
def _read_Args(node): args = node.findall('arg') if len(args) != 2: raise EduceXmlException( 'Was expecting exactly two arguments (got %d)' % len(args)) return tuple(map(_read_Arg, args))