Spaces:
Runtime error
Runtime error
Blair Yang
commited on
Commit
·
07a63f0
1
Parent(s):
abedf13
Update josn
Browse files
Sample.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import jsonlines
|
2 |
import random
|
3 |
import numpy as np
|
4 |
import os
|
@@ -95,8 +94,12 @@ def sample_card(dataset='', topic='', model='', card_cnt=2):
|
|
95 |
def sample_QA_entry(dataset='', topic='', model='', n=1):
|
96 |
path = f'dataset/{dataset}/{topic}/{topic}_test.jsonl'
|
97 |
# load jsonl
|
98 |
-
with jsonlines.open(path) as reader:
|
99 |
-
|
|
|
|
|
|
|
|
|
100 |
|
101 |
# transfer into pandas
|
102 |
df = pd.DataFrame(data)
|
|
|
|
|
1 |
import random
|
2 |
import numpy as np
|
3 |
import os
|
|
|
94 |
def sample_QA_entry(dataset='', topic='', model='', n=1):
|
95 |
path = f'dataset/{dataset}/{topic}/{topic}_test.jsonl'
|
96 |
# load jsonl
|
97 |
+
# with jsonlines.open(path) as reader:
|
98 |
+
# data = list(reader)
|
99 |
+
# use json
|
100 |
+
# load line by line
|
101 |
+
with open(path, 'r') as f:
|
102 |
+
data = [json.loads(line) for line in f.readlines()]
|
103 |
|
104 |
# transfer into pandas
|
105 |
df = pd.DataFrame(data)
|