-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringToString.html
More file actions
111 lines (93 loc) · 2.8 KB
/
stringToString.html
File metadata and controls
111 lines (93 loc) · 2.8 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<html>
<head>
<link rel="stylesheet" type="text/css" href="spot.css">
<script src="lib/jszip.min.js"></script>
<script src="prototypeInterface.js"></script>
<script src="tableauMaker.js"></script>
</head>
<body>
<h2>Automatic evaluation and tableau generation for strings by SPOT</h2>
<pre id="results-container"></pre>
<p>(c) Bellik & Kalivoda 2019</p>
<script>
//INPUTS
var inputs = ["A", "B", "C"];
//GEN
function gen(ip, outputs)
{
var cset = [];
for(var i = 0; i < outputs.length; i++)
{
cset.push([ip,outputs[i]]);
};
return cset;
}
//CONSTRAINTS
function faith(cand)
{
if(cand[0] == cand[1])
{
return 0;
}
else
{
return 1;
}
}
function noC(cand)
{
if(cand[1] == "C")
{
return 1;
}
else
{
return 0;
}
}
var con = ["faith", "noC"];
var conNames = ["con"];
//ANALYSIS
function makeTableauCsvs(consName){
var csvSegs = [];
//For each string in inputs, make a tableau using the current constraint set
for(var j=0; j<inputs.length; j++){
var currentInput = inputs[j];
//Make the candidate set using the GEN function (defined in candidategenerator.js)
//Leave the 2nd argument as an empty string to scrape words from the terminals of the syntactic tree.
var candSet = gen(currentInput, inputs);
//Make the tableau using the makeTableau function (defined in tableauMaker.js)
var tabl = makeTableau(candSet, window[consName]);
//Write the tableau to the screen and reveal it -- only uncomment this if you don't have too many tableaux!
writeTableau(tabl)
revealNextSegment();
lastSegmentId++;
//Add the tableau from the current stree to cumulative tableau that is being built in csvSegs.
csvSegs.push(tableauToCsv(tabl, '\t', {noHeader: j}));
}
//Save the tableau as a tab-separated file, named after consName
saveTextAs(csvSegs.join('\n'),"tableau_"+consName+".csv");
}
/*This function executes automatically when the page is reloaded. It calls all the other functions.*/
function runDemo() {
//Iterate over the different constraint sets. Make a tableau for each one.
for(var i = 0; i<conNames.length; i++){
makeTableauCsvs(conNames[i]);
}
}
/*Utilities for saving files.*/
function saveAs(blob, name) {
var a = document.createElement("a");
a.display = "none";
a.href = URL.createObjectURL(blob);
a.download = name;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
function saveTextAs(text, name) {
saveAs(new Blob([text], {type: "text/csv", encoding: 'utf-8'}), name);
}
</script>
</body>
</html>