1.json轉conll格式
https://github.com/explosion/spaCy/issues/1966
from spacy.gold import biluo_tags_from_offsets doc = nlp(u'I like London.') entities = [(7, 13, 'LOC')] tags = biluo_tags_from_offsets(doc, entities) assert tags == ['O', 'O', 'U-LOC', 'O']
比較簡便的方法是根據這個函數來轉換,但是不是轉換為BIO,而是BILUO格式,如下:
U表示單個實體,L表示長度>=2的實體的末尾。
如果想再轉換為BIO,可以寫一個腳本,應該還是比較簡單的。
2.conll轉換為json
https://stackoverflow.com/questions/58299682/how-to-import-text-from-connl-format-with-named-entities-into-spacy-infer-entit