-
Notifications
You must be signed in to change notification settings - Fork 7
/
demo.html
96 lines (92 loc) · 2.98 KB
/
demo.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<script src="vendor/js/jquery.min.js"></script>
<style>
#source {
margin: 10px;
padding: 10px;
border: 1px solid rgba(0, 0, 0, 0.5);
width: calc(100% - 42px);
height: 300px;
border-radius: 5px;
font-family: 'menlo', 'Courier New', Courier, monospace;
font-size: 14px;
}
#result {
margin: 10px;
padding: 10px;
background-color: rgb(234, 241, 244);
width: calc(100% - 42px);
border-radius: 5px;
font-family: 'menlo', 'Courier New', Courier, monospace;
font-size: 14px;
min-height: 30px;
}
#compile {
transition: 0.2s all;
cursor: pointer;
margin: 10px;
line-height: 35px;
padding: 0 20px;
background-color: rgba(109, 207, 246, 1);
color: white;
text-align: center;
border: none;
border-radius: 5px;
font-size: 16px;
}
#compile:hover {
background-color: rgb(90, 201, 245);
}
#compile:active {
background-color: rgb(37, 169, 221);
}
</style>
</head>
<body>
<textarea id="source" spellcheck="false"></textarea>
<div>
<span>Provenance:</span>
<select id="provenance">
<option value="unit">Unit</option>
<option value="minmaxprob">Min/Max Probability</option>
<option value="topkproofs">Top K Proofs</option>
<option value="topbottomkclauses">Top Bottom K Clauses</option>
</select>
<span>K (for <code>topkproofs</code> and <code>topbottomkclauses</code> provenance):</span>
<input id="top-k" type="number" value="3" />
<button id="compile">Run</button>
</div>
<pre id="result"></pre>
<script type="module">
import init, {
interpret,
interpret_with_minmaxprob,
interpret_with_topkproofs,
interpret_with_topbottomkclauses,
} from "/artifacts/scallop-wasm/scallop_wasm.js";
init().then(() => {
$("#compile").click(() => {
let scallop_source = $("#source").val();
let interpreted_result = "";
let provenance = $("#provenance").val();
if (provenance == "unit") {
interpreted_result = interpret(scallop_source);
} else if (provenance == "minmaxprob") {
interpreted_result = interpret_with_minmaxprob(scallop_source);
} else if (provenance == "topkproofs") {
let top_k = parseInt($("#top-k").val());
interpreted_result = interpret_with_topkproofs(scallop_source, top_k);
} else if (provenance == "topbottomkclauses") {
let top_k = parseInt($("#top-k").val());
interpreted_result = interpret_with_topbottomkclauses(scallop_source, top_k);
} else {
alert("Unknown provenance `" + provenance + "`");
}
$("#result").text(interpreted_result);
});
});
</script>
</body>
</html>