【发布时间】:2013-03-29 10:59:17
【问题描述】:
在尝试使用 stanford NRE 工具标记命名实体时,我得到了这种输出:
A jury in <ORGANIZATION>Marion County Superior Court</ORGANIZATION> was expected to begin deliberations in the case on <DATE>Wednesday</DATE> or <DATE>Thursday</DATE>.
当然,处理任何没有根的 XML 是行不通的,所以我添加了这个:
<root>A jury in <ORGANIZATION>Marion County Superior Court</ORGANIZATION> was expected to begin deliberations in the case on <DATE>Wednesday</DATE> or <DATE>Thursday</DATE>.</root>
我尝试使用这种方法构建一棵树:stripping inline tags with python's lxml,但它不起作用...它在tree = etree.fromstring(text) 行产生此错误:
lxml.etree.XMLSyntaxError: xmlParseEntityRef: no name, line 1, column 1793
有人知道这个的解决方案吗?或者也许是另一种方法,它允许我从任何带有 inlineXML 标记的文本构建树,只保留标记的标记并删除/忽略文本的其余部分。
【问题讨论】:
-
您要解析的实际“XML”的第 1793 列是什么?
&? -
根据 python (text[1793]),它是字母 'e'。文本中有多个 & 符号,第一个出现在 1953 年。
标签: python-3.x xml-parsing stanford-nlp inline-xml