python - 无法将 iob 转换为 spaCy 二进制格式
问题描述
我尝试将我的 IOB(每行令牌 NER)文件(训练/测试)转换为 Spacy 3 二进制格式。
输入格式示例(带分隔符“\t”,无空白行和编码 utf-8):
Département B-LOCATION
des I-LOCATION
Bouches-du-Rhône I-LOCATION
. O
Port B-INSTALLATION
de I-INSTALLATION
la I-INSTALLATION
Ciotat I-INSTALLATION
. O
Avant-projet O
du O
môle B-INSTALLATION
Bérouard I-INSTALLATION
au O
port B-INSTALLATION
de I-INSTALLATION
La I-INSTALLATION
Ciotat I-INSTALLATION
. O
当我运行时:
!python -m spacy convert -c iob -s -n 10 -b fr_core_news_sm /content/ner4archives_v0_train.iob .
!python -m spacy convert -c iob -s -n 10 -b fr_core_news_sm /content/ner4archives_v0_test.iob .
我有这个错误:
ValueError: [E903] The token-per-line NER file is not formatted correctly. Try checking whitespace and delimiters. See https://spacy.io/api/cli#convert
我看到了带有示例数据的 git 目录:https ://github.com/explosion/spaCy/tree/master/extra/example_data/ner_example_data ;但我找不到我的数据和示例之间的区别。
我尝试使用不同类型的分隔符(“\t”、“”、“|”)重新格式化我的文件,但我总是遇到同样的错误。此外,我测试了我是否有空标记或标签,它不是。
有线索的人吗?提前致谢。
解决方案
我认为您使用的 SpaCy 版本不是3.X
,我可以.spacy
使用您的输入创建二进制文件,下载后没有任何问题fr_core_news_sm
。
命令:
python -m spacy convert -c iob -s -n 10 -b fr_core_news_sm C:/git/sof/test.iob .
输出:
[i] Auto-detected token-per-line NER format
[i] Grouping every 10 sentences into a document.
[i] Segmenting sentences with parser from model 'fr_core_news_sm'.
[+] Generated output file (1 documents): test.spacy
SpaCy 版本:3.1.3
推荐阅读
- php - 如何在 php 中仅显示 mysql 数据库中的第一张图片
- javascript - nodemailer 电子邮件未发送且未记录错误
- javascript - 我正在尝试使用 node、nodemon、express 和 dotenv 发送电子邮件
- excel - 使用 VBA 替换 Excel 中的 Powerpoint 数据
- r - 如何获得由许多多边形从大栅格中剪裁的栅格中具有 NA 值的像素数?
- php - Laravel 和 Guzzle HTTP '406 不可接受'
- javascript - 从父元素javascript中删除类
- c# - 系统范围的全局列表变量是否存在
- javascript - 打字稿问题:受限制的属性类型不兼容
- r - 更改字符串中间单个字符的大小写