利用置换实现NER训练数据和实体的可视化

visualizing NER training data and entity using displacy(利用置换实现NER训练数据和实体的可视化)

本文介绍了利用置换实现NER训练数据和实体的可视化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为训练NER数据创建了一个数据集。在创建之后,我想在应用到训练管道之前测试实体和数据是否匹配。使用置换,我们可以以更好的方式可视化。而是如何在Spacy 3中实现它。

推荐答案

上述问题的代码如下

import spacy
from spacy import displacy


annot_data = [('A Very SoNA Christmas
View SoNA’s Covid Safety Policies
Skip to Content
About
History Mission
Staff Board
Music Director
Musicians
SoNA Singers
Auditions
Hire Ensembles
Contact
2021-22 Season
Subscriber Series
Ticketed Performances
SoNA Beyond Series
Virtual Performances
Virtual Performances
Solos from Home
Special Events
Fireworks at the Farm
Reimagined Celebration
Donate
Gallery
Education
Blog
Open Menu
Close Menu
About
History Mission
Staff Board
Music Director
Musicians
SoNA Singers
Auditions
Hire Ensembles
Contact
2021-22 Season
Subscriber Series
Ticketed Performances
SoNA Beyond Series
Virtual Performances
Virtual Performances
Solos from Home
Special Events
Fireworks at the Farm
Reimagined Celebration
Donate
Gallery
Education
Blog
Open Menu
Close Menu
Folder:
About
Folder:
2021-22 Season
SoNA Beyond Series
Folder:
Virtual Performances
Folder:
Special Events
Donate
Gallery
Education
Blog
Back
History Mission
Staff Board
Music Director
Musicians
SoNA Singers
Auditions
Hire Ensembles
Contact
Back
Subscriber Series
Ticketed Performances
Back
Virtual Performances
Solos from Home
Back
Fireworks at the Farm
Reimagined Celebration
A Very SoNA Christmas
Jul 10, 2021
Written By SoNA
Saturday, December 11, 2021 2PM 7:30PM Walton Arts Center, Fayetteville
A mix of sacred and secular holiday favorites with local guest soloists, The SoNA Singers, and area high school and collegiate choruses. Saturday, December 11, 2021 2PM Matinee Performance Saturday, December 11, 2021 7:30PM Evening Performance
Buy Tickets
Buy Tickets
Single Tickets: 35, 45, 57 Under 18 FREE with purchase of adult ticket limited quantities Interested in a full season subscription Learn more here . Concert sponsored by Bogle Family Foundation
We are committed to ensuring that audiences can experience music safely in person at our performances. Until further notice, patrons, staff, and volunteers are required to wear masks. Learn more about our safety policy here .
SoNA
Previous
Previous
Mozart and Beethoven
Next
Next
SoNA Walton Arts Center present The Snowman: A Family Concert
Receive the latest updates
Email Address
Sign Up
Thank you for joining our email list You should receive a verification email shortly to confirm.
Office: 479.521.4166 Tickets: 479.443.5600 infosonamusic.org
Copyright 2021, SoNA. All rights reserved.
Support SoNA',
  {'entities': [(1958, 1962, 'organization'),
    (1230, 1236, 'performance_starttime'),
    (1343, 1359, 'organization'),
    (1208, 1225, 'performance_date'),
    (1237, 1255, 'auditorium'),
    (0, 21, 'production_name'),
    (1226, 1229, 'performance_starttime')]})]

nlp = spacy.blank('en')
raw_text = annot_data[0][0]
doc = nlp.make_doc(raw_text)
spans = annot_data[0][1]["entities"]
ents = []
for span_start, span_end, label in spans:
    ent = doc.char_span(span_start, span_end, label=label)
    if ent is None:
        continue

    ents.append(ent)

doc.ents = ents
displacy.render(doc, style="ent", jupyter=True)

这篇关于利用置换实现NER训练数据和实体的可视化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:利用置换实现NER训练数据和实体的可视化

基础教程推荐