我是nlp的初学者,想从句子列表中生成IOB格式。
我具有以下格式的IOB格式的数据:
[('in', 'O'), ('this', 'B-DATE'), ('week', 'I-DATE'), ('how', 'O'), ('many', 'O'), ('activities', 'O'), ('do', 'O'), ('i', 'O'), ('have', 'O'), ('?', 'O')]
预期输出为
in O
this B-DATE
week I-DATE
how O
many O
activities O
do O
i O
have O
? O
答案 0 :(得分:0)
如果您需要一个仅包含由初始列表的成员组成的字符串的新list
,则可以尝试以下操作:
initial = [('in', 'O'), ('this', 'B-DATE'), ('week', 'I-DATE'), ('how', 'O'), ('many', 'O'), ('activities', 'O'), ('do', 'O'), ('i', 'O'), ('have', 'O'), ('?', 'O')]
modified = [' '.join(z) for z in initial]
for row in modified:
print(row)
输出:
in O
this B-DATE
week I-DATE
how O
many O
activities O
do O
i O
have O
? O