1 Star 1 Fork 3

Fly97/spo_lstm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
get_type.py 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
Fly97 提交于 2019-07-12 10:54 . updata
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")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/fly97/spo_lstm.git
git@gitee.com:fly97/spo_lstm.git
fly97
spo_lstm
spo_lstm
master

搜索帮助