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
评论列表
文章目录