예제 #1
0
파일: pdtbx.py 프로젝트: irit-melodi/educe
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))
예제 #2
0
파일: pdtbx.py 프로젝트: irit-melodi/educe
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)
예제 #3
0
파일: pdtbx.py 프로젝트: tjane/educe
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)
예제 #4
0
파일: xml_.py 프로젝트: chloebt/educe
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)
예제 #5
0
파일: xml_.py 프로젝트: chloebt/educe
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)
예제 #6
0
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)
예제 #7
0
파일: xml_.py 프로젝트: chloebt/educe
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)
예제 #8
0
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)
예제 #9
0
파일: pdtbx.py 프로젝트: tjane/educe
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)
예제 #10
0
파일: pdtbx.py 프로젝트: tjane/educe
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'))
예제 #11
0
파일: pdtbx.py 프로젝트: tjane/educe
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)
예제 #12
0
파일: glozz.py 프로젝트: eipiplusun/educe
 def get_one(name, default, ctx=None):
     f = lambda n: read_node(n, ctx)
     return on_single_element(node, default, f, name)
예제 #13
0
파일: xml_.py 프로젝트: chloebt/educe
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'))
예제 #14
0
 def get_one(name, default, ctx=None):
     f = lambda n: read_node(n, ctx)
     return on_single_element(node, default, f, name)