特にスペイシー トランスフォーマーを使用するために、スペイシー バージョンをナイトリーにアップグレードしようとしています。
だから私は次のような形式のスペイシーでシンプルな列車のデータセットを変換しました
td = [["Who is Shaka Khan?", {"entities": [(7, 17, "FRIENDS")]}],["I like London.", {"entities": [(7, 13, "LOC")]}],]
上から
[[{"head": 0, "dep": "", "tag": "", "orth": "Who", "ner": "O", "id": 0}, {"head": 0, "dep": "", "tag": "", "orth": "is", "ner": "O", "id": 1}, {"head": 0, "dep": "", "tag": "", "orth": "Shaka", "ner": "B-FRIENDS", "id": 2}, {"head": 0, "dep": "", "tag": "", "orth": "Khan", "ner": "L-FRIENDS", "id": 3}, {"head": 0, "dep": "", "tag": "", "orth": "?", "ner": "O", "id": 4}], [{"head": 0, "dep": "", "tag": "", "orth": "I", "ner": "O", "id": 0}, {"head": 0, "dep": "", "tag": "", "orth": "like", "ner": "O", "id": 1}, {"head": 0, "dep": "", "tag": "", "orth": "London", "ner": "U-LOC", "id": 2}, {"head": 0, "dep": "", "tag": "", "orth": ".", "ner": "O", "id": 3}]]
次のスクリプトを使用して
sentences = []
for t in td:
doc = nlp(t[0])
tags = offsets_to_biluo_tags(doc, t[1]['entities'])
ner_info = list(zip(doc, tags))
tokens = []
for n, i in enumerate(ner_info):
token = {"head" : 0,
"dep" : "",
"tag" : "",
"orth" : i[0].orth_,
"ner" : i[1],
"id" : n}
tokens.append(token)
sentences.append(tokens)
with open("train_data.json","w") as js:
json.dump(sentences,js)```
then i tried to convert this train_data.json using
spacy's convert command
```python -m spacy convert train_data.json converted/```
but the result in converted folder is
```✔ Generated output file (0 documents): converted/train_data.spacy```
which means it doesn't created dataset
can anybody help on what i am missing
i am trying to do this with spacy-nightly