我想将自定义数据标记为sklearn-crfsuite中提到的IOB标记,但是无法标记。我能够提取实体和实体名称的开始和结束索引。
我尝试将标记化的句子插入单词中并标记“ O”和“ B-ORG”(示例),但未标记“ I-ORG”。
from nltk import word_tokenize, pos_tag, ne_chunk
from nltk import conlltags2tree, tree2conlltags
tree = ne_chunk(pos_tag(word_tokenize("Google LLC is an American multinational technology company.")))
iob_tags = tree2conlltags(tree)
print(iob_tags)
我得到了什么
[('Google', 'NNP', 'B-PERSON')
('LLC', 'NNP', 'B-ORGANIZATION')
('is', 'VBZ', 'O')
('an', 'DT', 'O')
('American', 'JJ', 'B-GPE')
('multinational','NN', 'O')
('technology', 'NN', 'O')
('company', 'NN', 'O')
('.', '.', 'O')]
我只想IOB标记我的自定义数据集,该数据集具有使用IOB标记方案(元组列表:[(word,pos_tag,IOB标记)]标记的标记化语句,以使用sklearn-crfsuite
来训练ner[('Google', 'NNP', 'B-ORG')
('LLC', 'NNP', 'I-ORG')
('is', 'VBZ', 'O')
('an', 'DT', 'O')
('American', 'JJ', 'B-GPE')
('multinational','NN', 'O')
('technology', 'NN', 'O')
('company', 'NN', 'O')
('.', '.', 'O')]
如何用pos标签标记这些标记化的单词以达到所需的结果,或者如何使用IOB标记方案标记这些单词。