启动时用标签在子字符串中的最佳标记单词在&提供结尾指数[Python]
我正在尝试以串联格式格式化数据以进行NER任务(此信息在很大程度上无关紧要)。我要最佳实现的是 -
输入:
- text:
快速棕色狐狸跳过懒惰的狗。
- indices:
10 -18
(棕色狐狸),35-42
(懒狗)
所需的输出:
The O
quick O
brown X
fox X
jumps O
over O
the O
lazy Y
dog Y
. O
是否有单个通行方法来执行此操作(因为我有一个很多例子 - 超过100k)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:修订后的输入
输入:
其他单词的正常标签
添加句子中所有单词的
,首先用
normal_tag
现在浏览每个标签,并在输入tag_indices。对于索引中的每个
(启动,结束)
,将输入字符串切成substring
。对于此子字符串中的每个单词,将其适当地标记。
最终输出是在
tagged_words
字典输出中:
EDIT : Revised input
Input :
Add a normal tag for the other words
Now for all the words in the sentence, first tag it with
normal_tag
Now go through each tag and indices in the input
tag_indices
. For every(start, end)
in the indices, slice the input string to get asubstring
.For each word in this substring, tag it appropriately.
The final output is in the
tagged_words
dictionaryOutput :