tempEval_corpus.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:IBRel 作者: lasigeBioTM 项目源码 文件源码
def add_relation_to_doc(doc_element, relation):
    relationname = ET.SubElement(doc_element, "relation") #XML entity
    id = ET.SubElement(relationname, "id") #XML id
    id.text = convert_id(relation.pid)
    # id.append(ET.Comment(relation.entities[0].text + "+" + relation.entities[1].text))
    #id.text = str(len(doc_element.findall("entity"))) esta so comentado
    type = ET.SubElement(relationname, "type") #XML
    type.text = "TLINK"
    # entity1 = ET.SubElement(relationname, "parentsType")
    # entity1.text = "TemporalRelations"
    propertiesname = ET.SubElement(relationname, "properties") #XML
    source = ET.SubElement(propertiesname, "Source") # XML
    source.text = convert_id(relation.entities[0].eid)
    propertiesname.append(ET.Comment("Source:{}".format(relation.entities[0].text)))
    t = ET.SubElement(propertiesname, "Type") # XML
    t.text = "CONTAINS"
    target = ET.SubElement(propertiesname, "Target") # XML
    target.text = convert_id(relation.entities[1].eid)
    propertiesname.append(ET.Comment("Target:{}".format(relation.entities[1].text)))
    return doc_element
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号