Spaces:
Runtime error
Runtime error
update instance
Browse files- ape/instance.py +10 -12
ape/instance.py
CHANGED
@@ -80,9 +80,8 @@ def load_qa(file='./ape/data/qa_train.json'):
|
|
80 |
raw_data = json.load(open(file, encoding='UTF8'))
|
81 |
for i in raw_data:
|
82 |
input = i['text']
|
83 |
-
|
84 |
-
|
85 |
-
output.append({'问题': j["Q"], '回答': j["A"]})
|
86 |
output = json.dumps(output, ensure_ascii=False)
|
87 |
data.append((input, output))
|
88 |
return data
|
@@ -99,15 +98,14 @@ def upload_file(file):
|
|
99 |
|
100 |
def load_entity(file='./ape/data/entity_train.json'):
|
101 |
data = []
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
data.append((input, output))
|
111 |
return data
|
112 |
|
113 |
|
|
|
80 |
raw_data = json.load(open(file, encoding='UTF8'))
|
81 |
for i in raw_data:
|
82 |
input = i['text']
|
83 |
+
#只取一个QA不然容易超出模型输入长度
|
84 |
+
output = {'问题': i['annotations'][0]["Q"], '回答': i['annotations'][0]["A"]}
|
|
|
85 |
output = json.dumps(output, ensure_ascii=False)
|
86 |
data.append((input, output))
|
87 |
return data
|
|
|
98 |
|
99 |
def load_entity(file='./ape/data/entity_train.json'):
|
100 |
data = []
|
101 |
+
raw_data = json.load(open(file, encoding='UTF8'))
|
102 |
+
for i in raw_data:
|
103 |
+
input = i['text']
|
104 |
+
output = []
|
105 |
+
for j in i['labels']:
|
106 |
+
output.append({'类型': j[1], '实体': j[-1]})
|
107 |
+
output = json.dumps(output, ensure_ascii=False)
|
108 |
+
data.append((input, output))
|
|
|
109 |
return data
|
110 |
|
111 |
|