代码拉取完成,页面将自动刷新
import json
import numpy as np
from random import choice
from tqdm import tqdm
import io
import codecs
import sys
import re
def change():
schemas=[]
charid=[]
i=0
with io.open('Relation/origin_data/all_50_schemas',"r", encoding='utf-8') as fr:
for line in fr:
dic = json.loads(line.encode('utf-8'))
schemas.append(dic)
charid.append(dic['predicate'])
json_file = codecs.open("test_data/ccc.json", 'w', encoding='utf-8')
with codecs.open("test_data/bbb.json", 'r', 'utf-8') as fr:
for line in fr:
try:
dic = json.loads(line.encode('utf-8'))
except ValueError:
continue
print('text:', dic['text'])
for schema in schemas:
for spolist in dic['spo_list']:
if schema['predicate'] == spolist['predicate']:
spolist['object_type']=schema['object_type']
spolist['subject_type'] = schema['subject_type']
json.dump(dic, json_file, ensure_ascii=False)
json_file.write("\n")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。