gpt4 book ai didi

python - 使用位移可视化 NER 训练数据和实体

转载 作者:行者123 更新时间:2023-12-05 02:38:22 24 4
gpt4 key购买 nike

我已经创建了一个用于训练 NER 数据的数据集。创建后,我想在应用于训练管道之前测试实体和数据是否匹配。使用位移我们可以以更好的方式可视化。但是如何在 spacy 3 中完成。

最佳答案

上面问题的代码如下

import spacy
from spacy import displacy


annot_data = [('A Very SoNA Christmas\nView SoNA’s Covid Safety Policies\nSkip to Content\nAbout\nHistory Mission\nStaff Board\nMusic Director\nMusicians\nSoNA Singers\nAuditions\nHire Ensembles\nContact\n2021-22 Season\nSubscriber Series\nTicketed Performances\nSoNA Beyond Series\nVirtual Performances\nVirtual Performances\nSolos from Home\nSpecial Events\nFireworks at the Farm\nReimagined Celebration\nDonate\nGallery\nEducation\nBlog\nOpen Menu\nClose Menu\nAbout\nHistory Mission\nStaff Board\nMusic Director\nMusicians\nSoNA Singers\nAuditions\nHire Ensembles\nContact\n2021-22 Season\nSubscriber Series\nTicketed Performances\nSoNA Beyond Series\nVirtual Performances\nVirtual Performances\nSolos from Home\nSpecial Events\nFireworks at the Farm\nReimagined Celebration\nDonate\nGallery\nEducation\nBlog\nOpen Menu\nClose Menu\nFolder:\nAbout\nFolder:\n2021-22 Season\nSoNA Beyond Series\nFolder:\nVirtual Performances\nFolder:\nSpecial Events\nDonate\nGallery\nEducation\nBlog\nBack\nHistory Mission\nStaff Board\nMusic Director\nMusicians\nSoNA Singers\nAuditions\nHire Ensembles\nContact\nBack\nSubscriber Series\nTicketed Performances\nBack\nVirtual Performances\nSolos from Home\nBack\nFireworks at the Farm\nReimagined Celebration\nA Very SoNA Christmas\nJul 10, 2021\nWritten By SoNA\nSaturday, December 11, 2021 2PM 7:30PM Walton Arts Center, Fayetteville\nA 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\nBuy Tickets\nBuy Tickets\nSingle 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\nWe 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 .\nSoNA\nPrevious\nPrevious\nMozart and Beethoven\nNext\nNext\nSoNA Walton Arts Center present The Snowman: A Family Concert\nReceive the latest updates\nEmail Address\nSign Up\nThank you for joining our email list You should receive a verification email shortly to confirm.\nOffice: 479.521.4166 Tickets: 479.443.5600 infosonamusic.org\nCopyright 2021, SoNA. All rights reserved.\nSupport 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)

关于python - 使用位移可视化 NER 训练数据和实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69645737/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com