Exemplo n.º 1
0
 def from_xml(self, xml_str):
     doc = minidom.parseString(xml_str)
     self.pos = doc.firstChild.nodeName
     for child_node in doc.firstChild.childNodes:
         if child_node.nodeType == child_node.TEXT_NODE:
             continue
         if child_node.nodeName == "grounding":
             self.groundings = Groundings()
             self.groundings.from_xml(child_node.toxml())
         else:
             if is_word_type(child_node.nodeName):
                 w = {}
                 w["type"] = child_node.nodeName
                 w["text"] = child_node.getAttribute("text")
                 self.words.append(w)
             elif is_phrase_type(child_node.nodeName):
                 factor = Factor()
                 factor.from_xml(child_node.toxml())
                 self.children.append(factor)