File tree 4 files changed +42
-1
lines changed
4 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 1
1
.py [cod ]
2
+ * .jsonl
2
3
__pycache__ /
3
4
data /
4
5
annotated /
Original file line number Diff line number Diff line change
1
+ language : python
2
+ python :
3
+ - " 3.6"
4
+ install :
5
+ - pip install -r requirements.txt
6
+ - tar xvjf data.tar.bz2
7
+ - bunzip2 test/example.pred.dev.jsonl.bz2
8
+ script :
9
+ - python test/check.py
10
+ - python evaluate.py data/dev.jsonl data/dev.db test/example.pred.dev.jsonl
Original file line number Diff line number Diff line change @@ -6,6 +6,6 @@ ADD . /eval/
6
6
7
7
RUN pip install -r requirements.txt
8
8
RUN tar xvjf data.tar.bz2
9
- RUN bunzip2 test/example.pred.dev.jsonl.bz2
9
+ RUN bunzip2 -f test/example.pred.dev.jsonl.bz2
10
10
11
11
CMD python /eval/evaluate.py /eval/data/dev.jsonl /eval/data/dev.db /eval/test/example.pred.dev.jsonl
Original file line number Diff line number Diff line change
1
+ import json
2
+ from tqdm import tqdm
3
+ import os
4
+ import sys
5
+ sys .path .append (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
6
+ from lib .query import Query
7
+ from lib .dbengine import DBEngine
8
+
9
+
10
+ if __name__ == '__main__' :
11
+ for split in ['train' , 'dev' , 'test' ]:
12
+ print ('checking {}' .format (split ))
13
+ engine = DBEngine ('data/{}.db' .format (split ))
14
+ n_lines = 0
15
+ with open ('data/{}.jsonl' .format (split )) as f :
16
+ for l in f :
17
+ n_lines += 1
18
+ with open ('data/{}.jsonl' .format (split )) as f :
19
+ for l in tqdm (f , total = n_lines ):
20
+ d = json .loads (l )
21
+ query = Query .from_dict (d ['sql' ])
22
+
23
+ # make sure it's executable
24
+ result = engine .execute_query (d ['table_id' ], query )
25
+ if result :
26
+ for a , b , c in d ['sql' ]['conds' ]:
27
+ if str (c ).lower () not in d ['question' ].lower ():
28
+ raise Exception ('Could not find conditon {} in question {} for query {}' .format (c , d ['question' ], query ))
29
+ else :
30
+ raise Exception ('Query {} did not execute to a valid result' .format (query ))
You can’t perform that action at this time.
0 commit comments