-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.pl
64 lines (50 loc) · 1.33 KB
/
test.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
do_test(TP,0,0,FP):-
pos(X),
functor(X,P,A),
\+ current_predicate(P/A),!,
num_pos(TP),
num_neg(FP).
do_test(TP,FN,TN,FP):-
do_test_pos(TP,FN),!,
do_test_neg(TN,FP),!.
do_test_pos(0,0):-
\+ current_predicate(pos/1),!.
do_test_pos(TP,FN):-
aggregate_all(count,(pos(X),test_ex(X)),TP),
num_pos(NumPos),
FN is NumPos-TP.
do_test_neg(0,0):-
\+ current_predicate(neg/1),!.
do_test_neg(TN,FP):-
aggregate_all(count,(neg(X),test_ex(X)),FP),
num_neg(NumNeg),
TN is NumNeg-FP.
test_ex(X):-
timeout(T),
catch(call_with_time_limit(T, call(X)),time_limit_exceeded,false),!.
timeout(0.1).
num_pos(0):-
\+ current_predicate(pos/1),!.
num_pos(N):-
aggregate_all(count,pos(_),N),!.
num_neg(0):-
\+ current_predicate(neg/1),!.
num_neg(N):-
aggregate_all(count,neg(_),N),!.
get_predictions(S0,S1):-
pos(X),
functor(X,P,A),
\+ current_predicate(P/A),!,
findall(1, pos(_), S0),
findall(0, neg(_), S1).
get_predictions(S0,S1):-
findall(Y, (pos(X), test_pos_(X,Y)), S0),
findall(Y, (neg(X), test_neg_(X,Y)), S1).
test_pos_(X,1):-
timeout(T),
catch(call_with_time_limit(T, call(X)),time_limit_exceeded,false),!.
test_pos_(_,0).
test_neg_(X,0):-
timeout(T),
catch(call_with_time_limit(T, call(X)),time_limit_exceeded,false),!.
test_neg_(_,1).