You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于CoNLL2003自定义NER数据集:Chunk标签规则与自动化生成求助

关于CoNLL2003数据集Chunk标签规则与自动化生成的问题

我正在开展命名实体识别(NER)项目,基于CoNLL2003数据集创建自定义数据集,但无法理解该数据集中Chunk列的标注规则,不确定其是否基于词性(POS)标签或其他规则。希望能自动化生成自定义数据集的Chunk标签,无需手动标注。

测试示例(以数据集第一句为例)

句子:EU rejects German call to boycott British lamb.

已完成的步骤及代码

1. 分词

预期结果:['EU', 'rejects', 'German', 'call', 'to', 'boycott', 'British', 'lamb', '.']
实现代码:

import pandas as pd
import nltk
from nltk.tokenize import word_tokenize
from nltk import pos_tag, ne_chunk
import re
# Tokenize the sentence
tokens = word_tokenize(Sentence)
# Print the tokens
print(tokens)

2. POS标注

预期结果:['NNP', 'VBZ', 'JJ', 'NN', 'TO', 'VB','JJ', 'NN', '.'](对应编码:[22, 42, 16, 21, 35, 37, 16, 21, 7])
实现代码:

pos_tags = {'"': 0, "''": 1, '#': 2, '$': 3, '(': 4, ')': 5, ',': 6, '.': 7, ':': 8, '``': 9, 'CC': 10, 'CD': 11, 'DT': 12, 'EX': 13, 'FW': 14, 'IN': 15, 'JJ': 16, 'JJR': 17, 'JJS': 18, 'LS': 19, 'MD': 20, 'NN': 21, 'NNP': 22, 'NNPS': 23, 'NNS': 24, 'NN|SYM': 25, 'PDT': 26, 'POS': 27, 'PRP': 28, 'PRP$': 29, 'RB': 30, 'RBR': 31, 'RBS': 32, 'RP': 33, 'SYM': 34, 'TO': 35, 'UH': 36, 'VB': 37, 'VBD': 38, 'VBG': 39, 'VBN': 40, 'VBP': 41, 'VBZ': 42, 'WDT': 43, 'WP': 44, 'WP$': 45, 'WRB': 46}
# POS Tagging of the tokens
pos_tagged = pos_tag(tokens)
# Print the POS Tagged tokens
print(pos_tagged)
# Keep only the POS tags in a list
pos_tags_only = [pos_tags[tag] for word, tag in pos_tagged]
# Print the POS
print(pos_tags_only)

遇到的问题

无法生成符合要求的Chunk标签,预期标签为:['B-NP', 'B-VP', 'B-NP', 'I-NP', 'B-VP', 'I-VP','B-NP', 'I-NP', 'O'](对应编码:[11, 21, 11, 12, 21, 22, 11, 12, 0])。CoNLL2003使用的Chunk标签集如下:

# To start with, this is the chunk tag set used in conll2003 dataset
chunk_tags = {'O': 0, 'B-ADJP': 1, 'I-ADJP': 2, 'B-ADVP': 3, 'I-ADVP': 4, 'B-CONJP': 5, 'I-CONJP': 6, 'B-INTJ': 7, 'I-INTJ': 8, 'B-LST': 9, 'I-LST': 10, 'B-NP': 11, 'I-NP': 12, 'B-PP': 13, 'I-PP': 14, 'B-PRT': 15, 'I-PRT': 16, 'B-SBAR': 17, 'I-SBAR': 18, 'B-UCP': 19, 'I-UCP': 20, 'B-VP': 21, 'I-VP': 22}  

需求

  • 解释CoNLL2003数据集的Chunk标签标注规则
  • 提供Python代码实现自动化生成该标签,用于自定义数据集

内容的提问来源于stack exchange,提问作者Boudribila

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 00:47:54