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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Leetcode 234: Palindrome LinkedList(Leetcode 234:回文链接列表)
How do I read an Excel file directly from Dropbox#39;s API using pandas.read_excel()?(如何使用PANDAS.READ_EXCEL()直接从Dropbox的API读取Excel文件?)
subprocess.Popen tries to write to nonexistent pipe(子进程。打开尝试写入不存在的管道)
I want to realize Popen-code from Windows to Linux:(我想实现从Windows到Linux的POpen-code:)
Reading stdout from a subprocess in real time(实时读取子进程中的标准输出)
How to call type safely on a random file in Python?(如何在Python中安全地调用随机文件上的类型?)