1 Star 9 Fork 6

wanghuogen/DeepNER

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
convert_test_data.py 795 Bytes
一键复制 编辑 原始数据 按行查看 历史
zxx 提交于 2020-12-23 19:17 . first commit
import os
import json
from tqdm import trange
def save_info(data_dir, data, desc):
with open(os.path.join(data_dir, f'{desc}.json'), 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
def convert_test_data_to_json(test_dir, save_dir):
test_examples = []
# process test examples
for i in trange(1500, 1997):
with open(os.path.join(test_dir, f'{i}.txt'), encoding='utf-8') as f:
text = f.read()
test_examples.append({'id': i,
'text': text})
save_info(save_dir, test_examples, 'test')
if __name__ == '__main__':
test_dir = './tcdata/juesai'
save_dir = './data/raw_data_random'
convert_test_data_to_json(test_dir, save_dir)
print('测试数据转换完成')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/huogenwang/DeepNER.git
git@gitee.com:huogenwang/DeepNER.git
huogenwang
DeepNER
DeepNER
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385