提问人:Ralph Corrigan 提问时间:3/2/2023 更新时间:3/4/2023 访问量:62
Spacy displacy.render 生成不符合 xml 的 </br> 标签
Spacy displacy.render produces </br> tags which are not xml compliant
问:
我正在对各种文本使用 SPacy for NER。数据帧正在解析为 XML 以在 eXist-DB 中存储和分析,我想将可视化工具结果作为 html 进行存储和显示。目前为止,一切都好。但是,生成的 html 包含在 eXist-DB 中自动无效的标签:</br>
<!DOCTYPE html>
<html lang="xx">
<head>
<title>displaCy</title>
</head>
<body style="font-size: 16px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; padding: 4rem 2rem; direction: ltr">
<figure style="margin-bottom: 6rem">
<div class="entities" style="line-height: 2.5; direction: ltr"></br></br>Some text here </br> some more text
<mark class="entity" style="background: #33ff82; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;">
more text
<span style="font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem">LOC</span>
</mark>
more text </div>
</figure>
</body>
</html>
我可以写一些东西来浏览每个html文档并更改标签,但想知道是否有任何方法可以使displacy.render从一开始就生成符合xml的html?
答:
0赞
Ralph Corrigan
3/4/2023
#1
我已经通过运行应用了一个简单的(如果不优雅的)修复程序
re.sub(r"</br>,"<br/>",html)
在保存之前针对我的 html。这可行,但我仍然想知道我是否可以首先应用任何东西来阻止创建标签。</br>
评论